clc;

clear all;

close all;

f0 = 100;

fs = 800;

ts = 1/fs;

N = 512;

t = 0:ts:(N-1)*ts;


x= cos(2*pi*f0*t);

din = x;

ptTimes = 64;


dfft1 = fft(din, N, 2);


dfft2 = fft(din, ptTimes * N, 2);

figure(1);

plot(abs(dfft1));

%  xlim([0 N/2]);  

title('正常频谱');  


figure(2);

plot(abs(dfft2));

title('自动补零频谱');


din2 = zeros(1, ptTimes * N);

din2(1:N) = din;

dfft3 = fft(din2,ptTimes * N );

figure(3);

plot(abs(dfft3));

title('手动补零频谱');


%手动补零,和自动补零,效果一样。  

% 补零后频谱, 比原来要细腻一些。