That assignment had 2 part I already complated part 1 and co
That assignment had 2 part. I already complated part 1. and collected the phasor frequency and magnitude datas. My code is here: I need to write a new code to answer those question. Please help me i dont know how to do those. Many thanks.
You can find .wav file from this website any .wav file will be okay. http://www.grsites.com/archive/sounds/category/10/
HERE IS MY PART 1 OF THIS ASSIGNMENT CODE.
clc
clear all
[y, Fs] = audioread(\'chirp.wav\'); % Reading file
Fs = 8192; % Sampling frequency
N=length(y);
T=1/Fs;
Fmax=Fs/2;
T0=N*T; %duration of the signal.
t =[1/Fs:1/Fs:N/Fs] % Time Vector
sound(y,Fs); % Plays .wav file
hold on
subplot(3,1,1);
plot(t,y, \'c\'); % Plots input signal
xlabel(\'Time\');
ylabel(\'Amplitude\');
title(\'Input Signal\')
Xr=fft(y); %use FFT to find DFT
freq1 =[-Fmax:Fs/N:Fmax-(Fs/N)];
%freq1 = linspace(1,Fs,length(y)); %%%frequency vector
subplot(3,1,2);
a=fftshift(Xr);
c=abs(a);
plot(freq1, c, \'r\'); %%%Stem Plot
xlabel(\'Freq\');
ylabel(\'Amplitude\');
title(\'Fourier Transform (Magnitude)\');
Xr_phase=angle(a); %Calculation of %phase
subplot(3,1,3);
plot(freq1,Xr_phase,\'g\') %Use %fftshift to %shift zero frequency component
xlabel(\'Phase\');
ylabel(\'Frequency\');
title(\'Phase Plot\');
%%% saving text file in ASCII foramt%%
% 1st column- frequency%%
% 2nd column- magnitude components%%
% 3rd column- phase (deg) components%%
A(:,1)=freq1;
A(:,2)=c;
A(:,3)=Xr_phase;
save(\'parameters.txt\',\'A\', \'-ASCII\')
Signal Synthesizer (part-2) 1. Read the analyzed value (magnitude, phase and frequency) from ASCII files. 2. Re-create sinusoid using the following equation for each set of (magnitude, phase and frequency) A Cos (2nft G) 3. Combine all sinusoids and plot the signal (this is regenerated signal). 4. Compare this combined signal with original chirp signal 5. Play the regenerated signal (It should sound like the original audio signal). 6. Store the synthesized audio signal in a WAV file (name it chirp synthesized.wav).Solution
freq2=A(:,1)\'%freq Components;
c2=A(:,2)\';%magnitude components
Xr_phase2=A(:,3)\'; %phase (deg) components%%;
for i=1:1:length(c2)
signalA(i)=c2(i)*cos((2*pi*freq2(i)*t(i))+Xr_phase2(i));
end
figure(2)
plot(t,signalA);
sound(signalA,Fs);

