Program Code
%IDFT program without functionclc;
close all;
clear all;
X=input('Enter the sequence');
N=input('Enter the length of the IDFT');
len=length(X);
if N>len
X=[X zeros(1,N-len)];
elseif N<len
X=X(1:N);
end
i=sqrt(-1);
w=exp(-i*2*pi/N);
n=0:(N-1);
k=0:(N-1);
nk=n'*k;
W=w.^(-nk);
x=(X*W)/N;
disp(x);
subplot(211);
stem(k,abs(x));
title('Magnitude Plot');
xlabel('N');
ylabel('Amplitude');
grid on;
subplot(212);
stem(k,angle(x));
title('Phase Plot');
xlabel('N');
ylabel('Phase Angle');
grid on;
Example of Output
Enter the sequence [24.0000 -2.3264 -13.6637i 3.0930 + 4.7651i 1.2334 - 6.2528i 1.2334 + 6.2528i 3.0930 - 4.7651i -2.3264 +13.6637i]Enter the length of the IDFT 4
6.1917 - 2.2247i 7.1913 + 2.0611i 5.8083 - 4.6072i 4.8087 + 4.7708i
_________________________
thank u so much!!
ReplyDeleteYou are always welcome. It is my pleasure.
DeleteYou are always welcome to visit this humble blog of mine. I am the author of this blog. My name is Anju K.