function ndft()
%plots the frequency and phase spectrum of N samples of the signals
M=10; %no. of samples taken to plot each sample of the fequency and phase spectrum
A=input('Enter the magnitude ');
N=100;
n=1:M;
x(n)=A;
x(M+1:N)=0;
y(1:N)=0;
for k=1:N
for n=1:M
y(k)=y(k)+x(n)*exp(-j*2*pi*(k-1)*(n-1)/N);
end
end
k=0:N-1;
subplot(3,1,1);
stem(k,x(k+1));
title('input');
subplot(3,1,2);
stem(k,abs(y(k+1)));
title('frequency spectrum');
subplot(3,1,3);
stem(k,angle(y(k+1)));
title('phase spectrum');
PLEASE LEAVE A COMMENT :)
%plots the frequency and phase spectrum of N samples of the signals
M=10; %no. of samples taken to plot each sample of the fequency and phase spectrum
A=input('Enter the magnitude ');
N=100;
n=1:M;
x(n)=A;
x(M+1:N)=0;
y(1:N)=0;
for k=1:N
for n=1:M
y(k)=y(k)+x(n)*exp(-j*2*pi*(k-1)*(n-1)/N);
end
end
k=0:N-1;
subplot(3,1,1);
stem(k,x(k+1));
title('input');
subplot(3,1,2);
stem(k,abs(y(k+1)));
title('frequency spectrum');
subplot(3,1,3);
stem(k,angle(y(k+1)));
title('phase spectrum');
PLEASE LEAVE A COMMENT :)
0 comments:
Post a Comment