t=0:0.1:20.5;
N=length(t);
dt=t(2)-t(1);
f1=11;
f2=1/3;
f3=3;
f4=1;
x=5*sin(2*pi*t*f1)+3*cos(2*pi*t*f2)+2*sin(2*pi*t*f3)+1*sin(2*pi*t*f4);
fx=fft(x)/N;
fp=(0:N/2)/N/dt;
fm=-fp(length(fp)-1:-1:2);
freq=[fp,fm];
plot(freq,abs(fx),'rx')
tb=0:0.1:200.5;
Nb=length(tb);
xb=5*sin(2*pi*tb*f1)+3*cos(2*pi*tb*f2)+2*sin(2*pi*tb*f3)+1*sin(2*pi*tb*f4);
fxb=fft(xb)/Nb;
fpb=(0:Nb/2)/Nb/dt;
fmb=-fpb(length(fpb)-1:-1:2);
freqb=[fpb,fmb];
hold on
plot(freqb,abs(fxb),'ko')
hold off