效果演示详见:
Matlab代码如下:
一、方波信号
clc;clear
%%20220926 努比熊爱吃土豆丝
%A信号幅值
%n信号个数
%pause图像暂停时间
%axis图像显示范围
A = 50;
w = 0.2;
t = linspace(0,20*pi,2000);
x1 = zeros(1,2000);
for n = 1 : 25
pause(2);
for i = 0:n-1
j = 2*i+1;
x1 = x1+4*A/(pi*j)*sin(j*w.*t);
end
k = 2*(n-1)+1
xn = 4*A/(pi*k)*sin(k*w.*t);
x = x1;
figure(1)