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 Spectrum of Signal');
xlabel('Normalized frequency');
ylabel('|X(e^{j\omega})|');
subplot(2,1,2);
plot(w/pi,angle(X));
grid on;
title('Phase Spectrum of Signal');
xlabel('Normalized Frequency');
ylabel('Phase')
To embed this project on your website, copy the following code and paste it into your website's HTML: