DSP Lab 2
DSP Lab 2
Lab 2
for i=1:n
x(i) = input('Enter the element');
end
disp('Sequence x[n] = ')
disp(x)
y=fft(x,2.^n);
subplot(2,1,1);
plot(abs(y));
title('Magnitude of System')
xlabel('Frequency')
ylabel('Magnitude')
subplot(2,1,2);
plot(angle(y));
title('Phase of System')
xlabel('Frequency')
ylabel('Phase')
Figure 1 Fourier transform of the given sequence
2. Compute the discrete time Fourier transform of the following function analytically and
then Plot the magnitude and phase
x(n) = 𝟑(𝟎. 𝟗)𝒏 𝒖(𝒏)
Analytical calculation
Plotting the magnitude and phase
w = -pi : 0.1 : pi;
y = 3./(1-0.9*exp(-1i*w));
%%Magnitude Response of FFT of system
subplot (2,1,1)
plot (w,abs(y))
title ('Response of Magnitude ')
xlabel('Frequency')
ylabel('Magnitude')
subplot (2,1,1)
plot( w ,abs (f))
title ('magnitude ')
xlabel ('frequency')
ylabel ('Amplitude')
subplot (2,1,2)
plot( w ,phase (f))
title (' phase ')
xlabel ('frequency')
ylabel ('Amplitude')
Figure 3 magnitude and phase for the H(w) of system
subplot (4,2,1)
plot (w, abs (H_w))
title('Magnitude Response')
xlabel('Frequency')
ylabel('Magnitude')
subplot (4, 2, 2)
plot (w, angle (H_w))
title ('Phase Response')
xlabel ('Frequency')
ylabel('Magnitude')
subplot (4,2,3)
plot (w, real (H_w))
title('Real Response')
xlabel('Frequency')
ylabel('Real Value')
subplot (4,2,4)
plot (w, imag (H_w))
title ('Imaginary Response')
xlabel ('Frequency')
ylabel('Imaginary Value')
subplot (4,2,5)
plot (w, abs (f))
title('Magnitude Response')
xlabel ('Frequency')
ylabel('Magnitude')
subplot (4,2,6)
plot (w, angle (f))
title('Phase Response')
xlabel('Frequency')
ylabel ('Magnitude')