%a sample signal with its time vector
clear; close all
n=512;m=n/2;
t = (0:(1/n):1)';
y = sin(2*pi*50*t) + 2*cos(2*pi*120*t);
kk=linspace(0,512,513)';
%------------------------FFT-------------------
z1=fft(y(1:n));
x1=real(ifft(z1));
%----------------------FFTRecur----------------
z2=FFTRecur(y(1:n));
P2=struct('a',real(z2(1:m+1))/m,'b',imag(z2(2:m))/m);
P2.a(1)=P2.a(1)/2;P2.a(m+1)=P2.a(m+1)/2;
x2 = CSeval(P2,1,t);
%-----------------------DFT--------------------
z3=DFT(y(1:n),1);
P3=struct('a',real(z3(1:m+1))/m,'b',imag(z3(2:m))/m);
P3.a(1)=P3.a(1)/2;P3.a(m+1)=P3.a(m+1)/2;
x3 = CSeval(P3,1,t);
%----------------------------------------------
plot(kk(1:50),y(1:50),'o',kk(1:50),x2(1:50))
%axis([ 0 100 -.05 2.05])
%set(gca,'xTick',linspace(0,100,13))