matlab 绘制原始信号的谐波

  这里以锯齿信号为例:

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

  运行结果:

matlab 绘制原始信号的谐波_第1张图片

 

转载于:https://www.cnblogs.com/darkchii/p/11222049.html

你可能感兴趣的:(matlab 绘制原始信号的谐波)