clear all
t=0.1:0.1:20;
tb=0.1:1:20;
N=length(t);
Nb=length(tb);
dt=t(2)-t(1);
dtb=tb(2)-tb(1);
f1=15.3;
f2=6.7;
x=5*sin(2*pi*t*f1)+3*cos(2*pi*t*f2);
xb=5*sin(2*pi*tb*f1)+3*cos(2*pi*tb*f2);
subplot(211)
plot(t,x,tb,xb)
fx=fft(x)/N;
fp=(0:N/2)/N/dt;
fm=-fp(length(fp)-1:-1:2);
freq=[fp,fm];
fxb=fft(xb)/Nb;
fpb=(0:Nb/2)/Nb/dtb;
fmb=-fpb(length(fpb)-1:-1:2);
freqb=[fpb,fmb];
subplot(212)
plot(1./freq,abs(fx),'r',1./freqb,abs(fxb),'kx')
