t=0:0.001:1;
f1=sin(10*pi*t)+sin(100*pi*t)+sin(200*pi*t);
f2=sin(200*pi*t)+sin(10*pi*t)-sin(100*pi*t);
figure(1);
plot(t,f1,t,f2);
figure(2);
t=1000*(1:512)/1024;
ff1=fft(f1,1024)/1024;
dff1=2*abs(ff1(1:512));
ff2=fft(f2,1024)/1024;
dff2=2*abs(ff2(1:512));
plot(t,dff1,t,dff2);
选采样频率时注意采样定律和波形的周期(采样频率不低于200Hz,周期不小于0.2s)