|
matlab的fft(x)函数, 若长度非2的整数幂, 其实是DFT不会自动补零, 除非给定fft(x,n), n>length(x)
试试下面程序
fs=5000000; tt=[0:1/fs:0.0001]; tt=tt(1:200); Sol=[];
fnA=[50000]; nlengf=length(fnA);
for ii1=1:nlengf, fn=fnA(ii1); dd=sin(2*pi*fn*tt); figure; plot(tt,dd); grid;
fftlengA=[200:14:256]; nleng=length(fftlengA);
for ii=1:nleng, fftleng=fftlengA(ii);
spec=fft(dd,fftleng); ind=[1:fftleng/2+1]'; spec=abs(spec(ind))*2/fftleng; Hz=(ind-1)*fs/fftleng;
figure; stem(Hz,spec); grid;
tRms=sqrt(sum(dd.^2)/length(dd)); fRms=sqrt(sum(spec.^2))/sqrt(2);
Sol=[Sol; fftleng, tRms, fRms, std(dd), std(dd,1)];
end
end
disp(Sol) |
|