Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2008-04-24
年龄: 38
帖子: 1
声望力: 0 ![]() |
![]()
在运行一下程序是会出现Error: Missing variable or function.是怎么回事啊?
display('Please input the value of m(傅立叶级数展开的项数)'); m=input('m='); t=-2*pi:0.01:2*pi; n=round(length(t)/4); f=[ones(n,1);-1*ones(n,1);ones(n,1);-1*ones(n+1,1)]; y=zeros(m+1,mas(size(t))); y(m+1, ![]() figure(1); plot(t/pi,y(m+1, ![]() grid; axis([-2 2 -1.5 1.5]); title('周期方波'); xlable('单位': pi','Fontsize',8); x=zeros(size(t)); kk='1'; for k=1:2:2*m-1 pause; x=x+sin(k*t)/k; y((k+1)/2, ![]() plot(t/pi,y(m+1, ![]() hold on; plot(t/pi,y((k+1)/2, ![]() hold off; grid; axis([-2 2 -1.5 1.5]); title(strcat('第',kk,'次谐波叠加')); xlabel('单位': pi','Fontsize',8); kk=strcat(kk,'、',num2str(k+2)); end pause; plot(t/pi,y(1:m+1, ![]() grid; axis([-2 2 -1.5 1.5]); title('各次谐波叠加波形'); xlabel('单位: pi','Fontsize',8); |
![]() |
![]() |