Just create a new file with extension .m and paste the code below in that .m file. Then Run it.
clc;
clear all;
x=input('Enter the sequence X(k) : ');
N=input('\nEnter the value of no. of points N : ');
L=length(x);
if(N>=L)
x=[x zeros(1,N-L)];
error('Length of sequence must be less than no. of points.\n');
end
for n=0:1:N-1
IDFT(n+1)=0;
for k=0:1:N-1
IDFT(n+1)=IDFT(n+1)+(1/N)*x(k+1)*exp(2*pi*j*k*n/N);
end
end
fprintf('IDFT of X(k) is x(k). Then ')
IDFT
No comments:
Post a Comment