DIGITAL SIGNAL PROCESSING SECTION: F
POST LAB 7 Question # 1 Attach plots of in lab tasks.
1 SUBMITTED TO: MS.UZMA PARVEEN OCTOBER 12th , 2016.
MAAZ HUSSAIN EE-196
DIGITAL SIGNAL PROCESSING SECTION: F
MAAZ HUSSAIN EE-196
Question # 2: Observe the DFT magnitude plot for x (t) =sin (2ni000t) +0.5sin (2n2000t+ (3n /4)) And prove that X (0) is equal to N times x (n)'s Average value.
CODE: clear all; close all; clc; t=0:.00001:10e-3; xt=1+sin(2*pi*1000*t)+0.5*s in(2*pi*2000*t+(3*pi/4)); N=80; % Length of DFT n=0:N-1; Fs=8000; Ts=1/Fs; xn=1+sin(2*pi*1000*n*Ts)+0. 5*sin(2*pi*2000*n*Ts+(3*pi/ 4)); t1 = n.*Ts; %code block to plot the input sequence subplot(411); plot(t,xt,'r'); hold on stem(t1,xn,'filled'); xlabel ('Time (sec)'); ylabel ('Amplitude'); title('Input signal') grid %------------------------Xk=zeros(1,N); %initialize an array of same size as that of input sequence iXk=zeros(1,N); %initialize an array of same size as that of input sequence %code block to find the DFT of the sequence j=sqrt(-1); %-------------------------for k=0:N-1 for n=0:N-1
2 SUBMITTED TO: MS.UZMA PARVEEN OCTOBER 12th , 2016.
phase=angle(round(Xk)); % Find the phases of individual DFT points phase=(phase.*180)/pi; %code block to plot the phase spectrum %------------------------subplot(413); stem(Fk,phase,'filled','r'); xlabel ('Frequency (Hz)'); ylabel ('Phase'); xlim([0 Fs]) title('Phase Spectrum') grid %-------------------%Code block to find the IDFT of the sequence % -------------for n=0:N-1 for k=0:N-1 iXk(n+1)=iXk(n+1)+(Xk(k+1)*exp(j*2*pi *k*n/N)); end end iXk=iXk./N; %-------------------------------------------------------------------------%code block to plot the time domain synthesized input sequence %-------------------------------------------------------------------------subplot(414); stem(t1,iXk,'filled'); xlabel ('Time (sec)'); ylabel ('Amplitude');
DIGITAL SIGNAL PROCESSING SECTION: F Xk(k+1)=Xk(k+1)+(xn(n+1)*ex p((-j)*2*pi*k*n/N)); end end %----------------------------magnitude=abs(Xk); % Find the magnitudes of individual DFT points %code block to plot the magnitude spectrum %-----------------------------k=0:N-1; Df = Fs/N; Fk = k.*Df; % Analysis frequencies subplot(412); stem(Fk,magnitude,'filled', 'r'); xlabel ('Frequency (Hz)'); ylabel ('Magnitude'); xlim([0 Fs]) title('Magnitude Spectrum') grid
MAAZ HUSSAIN EE-196 title('Synthesized Input signal from IDFT') grid %proof: fprintf('- the value of X(0)(the first DFT output) = %f\n',magnitude(1,1)) fprintf('- the average of xn = %f \n',mean2(xn)) fprintf('multiplying average of x(n) with N = %f = to X(0)\n',N*mean2(xn))
Prove: • The value of X(0)(the first DFT output) is 80.000000 • The average of xn is 1.000000 • multiplying average of x(n) with N is 80.000000 that is X(0) The averaging value of x(n) gives the value of dc offset In this case is the dc offset value is 1 and it is proved that x(n) . N=X(0)
3 SUBMITTED TO: MS.UZMA PARVEEN OCTOBER 12th , 2016.
DIGITAL SIGNAL PROCESSING SECTION: F
MAAZ HUSSAIN EE-196
Question # 3 Attach plots and Interpret results of Q2 PLOT:
COMMENTS: It was observed that:
the value of X(0)(the first DFT output) is 80.000000 the average of xn is 1.000000 multiplying average of x(n) with N is 80.000000 that is X(0) The averaging value of x(n) gives the value of dc offset. In this case is the dc offset value is 1 and it is proved that x(n) . N=X(0)
4 SUBMITTED TO: MS.UZMA PARVEEN OCTOBER 12th , 2016.
DIGITAL SIGNAL PROCESSING SECTION: F
5 SUBMITTED TO: MS.UZMA PARVEEN OCTOBER 12th , 2016.
MAAZ HUSSAIN EE-196