MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB工具箱] matlab周期信号傅里叶展开求助 (https://www.labfans.com/bbs/showthread.php?t=9879)

scnyliuzw 2009-10-13 11:52

matlab周期信号傅里叶展开求助
 
[I]%周期信号的傅里叶级数展开;
display('输入傅里叶级数展开的项数m:');
m=input('m=');
t=-2*pi:0.01: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,max(size(t)));
[B]y(m+1,:)=f';[/B]提示有错,我也不知道这是什么意思,请问能解释下吗?
figure(1);
plot(t/pi,y(m+1,:));
grid;
axis([-2,2,-1.5,1.5])
title('周期方波')
xlabel('单位: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,:)=4/pi*x;
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(stract('第',kk,'次谐波叠加'));
xlabel(' 单位:pi','Fontsize,8');
kk=stract(kk,'、',num2str(k+2));
end
pause;
plot(t/pi,y(m+1,:));
grid;
axis([-2 2 -1.5 1.5]);
title('各次谐波叠加')
xlabel('单位:pi','Fontsize',8);:mad:
%end[/I]


所有时间均为北京时间。现在的时间是 03:37

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.