In: Electrical Engineering
given the sequences
x1 = [2, 6, -4, 1]
x2 = [8, 0, 2, 0, -9, 0, 1, 0]
x3 = [2, 0, -8, -8, 2]
x4 = [0, 1, 5i, 0, 6i, 0]
x5 = [9, 3, 7]
plot the
1. DFT magnitude of the computed sequences in MATLAB
2. phase responses in degrees and radians against frequency and
number of samples
3. comment on the plots
clc;
close all; clear
x1 = [2 6 -4 1];
x2 = [8 0 2 0 -9 0 1 0];
x3 = [2 0 -8 -8 2];
x4 = [0 1 5i 0 6i 0];
x5 = [9 3 7];
y1 = fft(x1); % Compute DFT of x
y2 = fft(x2);
y3 = fft(x3);
y4 = fft(x4);
y5 = fft(x5);
m1 = abs(y1); % Magnitude
m2 = abs(y2);
m3 = abs(y3);
m4 = abs(y4);
m5 = abs(y5);
p1 = unwrap(angle(y1)); % phase
p2 = unwrap(angle(y2));
p3 = unwrap(angle(y3));
p4 = unwrap(angle(y4));
p5 = unwrap(angle(y5));
f1 = (0:length(y1)-1)*100/length(y1); % Frequency vector
f2 = (0:length(y2)-1)*100/length(y2);
f3 = (0:length(y3)-1)*100/length(y3);
f4 = (0:length(y4)-1)*100/length(y4);
f5 = (0:length(y5)-1)*100/length(y5);
figure
subplot(3,1,1)
plot(f1,m1)
title('Magnitude x1')
subplot(3,1,2)
plot(f1,p1*180/pi)
title('Phase degree x1')
subplot(3,1,3)
plot(f1,p1*180/pi)
title('Phase radian x1')
figure
subplot(3,1,1)
plot(f2,m2)
title('Magnitude x2')
subplot(3,1,2)
plot(f2,p2*180/pi)
title('Phase degree x2')
subplot(3,1,3)
plot(f1,p1)
title('Phase radian x2')
figure
subplot(3,1,1)
plot(f3,m3)
title('Magnitude x3')
subplot(3,1,2)
plot(f3,p3*180/pi)
title('Phase degree x3')
subplot(3,1,3)
plot(f1,p1)
title('Phase radian x3')
figure
subplot(3,1,1)
plot(f4,m4)
title('Magnitude x4')
subplot(3,1,2)
plot(f4,p4*180/pi)
title('Phase degree x4')
subplot(3,1,3)
plot(f1,p1)
title('Phase radian x4')
figure
subplot(3,1,1)
plot(f5,m5)
title('Magnitude x5')
subplot(3,1,2)
plot(f5,p5*180/pi)
title('Phase degree x5')
subplot(3,1,3)
plot(f1,p1)
title('Phase radian x5')