加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

matlab中用正弦波叠加生成方波

(2018-03-03 09:32:38)

程序如下:

http://s15/mw690/005Sx9ZRzy7iB7QoHGSee&690





http://s8/mw690/005Sx9ZRzy7iB7V0soD57&690

http://s15/mw690/005Sx9ZRzy7iB7VGFPwbe&690

http://s16/mw690/005Sx9ZRzy7iB7WWwhhdf&690

figure(1);
ts=0.0001;
t=0:ts:4*pi;
f=1/ts;
N=length(t);
y1=square(0.32*pi*t);
plot(t,y1);
title('产生一个方波');
pause;
hold on;
figure(2);
subplot(3,2,1);
y2=4/pi*sin(t);
plot(t,y2);
title('正弦基波');
subplot(3,2,2);
y3=4/pi*(sin(3*t)/3);
plot(t,y3);
title('三次谐波');
subplot(3,2,3);
y4=4/pi*(sin(5*t)/5);
plot(t,y4);
title('五次谐波');
subplot(3,2,4);
y5=4/pi*(sin(7*t)/7);
plot(t,y5);
title('七次谐波');
subplot(3,2,5);
y6=4/pi*(sin(9*t)/9);
plot(t,y6);
title('九次谐波');pause
figure(3);
subplot(2,2,1);
y7=4/pi*(sin(t)+sin(3*t)/3);
plot(t,y7);
title('前两次谐波叠加');
subplot(2,2,2);
y8=4/pi*(sin(t)+sin(3*t)/3+sin(5*t)/5);
plot(t,y8);
title('前三次谐波叠加');
subplot(2,2,3);
y9=4/pi*(sin(t)+sin(3*t)/3+sin(5*t)/5+sin(7*t)/7);
plot(t,y9);
title('前四次谐波叠加');
subplot(2,2,4);
y10=4/pi*(sin(t)+sin(3*t)/3+sin(5*t)/5+sin(7*t)/7+sin(9*t)/9);
plot(t,y10);
title('前五次谐波叠加');
y=zeros(10,max(size(t)));
x=zeros(size(t));
for k=1:2:15
    x=x+4/pi*(sin(k*t)/k);
    y((k+1)/2,:)=x;
end
pause;
figure(4);
plot(t,y(1:9,:));
title('各波形叠加');

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有