这里以锯齿信号为例:
clear;clc; figure time = 0:1/20:1000; wave = sawtooth(time); subplot(3, 1, 1); plot(time, wave); samples = length(wave); sampling = 100; ampl = zeros(sampling, floor(samples/sampling)); frame = 1; for i=0:sampling:samples first = max(1,i+1); last = min(samples,i+sampling); ampl(1:sampling, frame) = abs(fft(wave(first:last))); frame = frame + 1; end subplot(3, 1, 2); for i=1:sampling plot3(0:1:samples/sampling, ones(1, floor(samples/sampling) + 1) * i, ampl(i,:)); hold on end subplot(3, 1, 3); for i=1:samples/sampling plot3(0:1:sampling - 1, ones(1, sampling) * i, ampl(:,i)); hold on %drawnow end
运行结果: