clc;
clear;
close all;
n = 0:20;
x = sin(0.2*pi*n);
w = -pi:0.01:pi;
X = zeros(size(w))
for k = 1:length(w)
X(k) = sum(x.*exp(-1j*w(k)*n));
end
subplot(2,1,1);
plot(w/pi,abs(X));
grid on;
title('magnitude  specturum of signal');
xlalbel('normalised frequency');
ylabel('|X(e^{j\omega})|');
subplot(2,1,2);
plot(w/pi,angle(X));
grid on;
title('phase specturum of signal');
xlabel('mormalised frequency');
ylabel('phase');

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: