Thursday, March 7, 2013

Simple DFT using FFT command in matlab


clear all;
for n =1:20,
    sign1(n)=0.5*cos(2*pi*n/10); %sinal to convert, f=10 Hz
end

XK(1:20)=0;
for k =1:20
    for n=1:20
    XK(k)=XK(k)+sign1(n)*exp(-j*2*pi*n*k/20); %convert with math
    end
end

%using fft command
XK2=fft(sign1,20); %convert with command
XK2(1)=[];
stem(XK);
plot();
stem(XK2)

Share:

0 comments:

Post a Comment