我创建了此代码,以便在不使用傅立叶级数命令的情况下计算和绘制傅立叶系数 A0、An 和 Bn,但不幸的是,绘图结果看起来不像傅立叶级数。如果有人请指导我解决这个问题。谢谢你
我确定了我将在这个项目中使用的所有术语
T=1; %Time Period
wo=2*pi/T;
a0=0;% coefficient
A0=0;% coefficient
a1=0;% coefficient
A1=0;% coefficient
a2=0;% coefficient
A2=0;% coefficient
a3=0;% coefficient
A3=0;% coefficient
a4=0;% coefficient
A4=0;% coefficient
a5=0;% coefficient
A5=0;% coefficient
a6=0;% coefficient
A6=0;% coefficient
a7=0;% coefficient
B7=0;% coefficient
b1=0;% coefficient
B1=0;% coefficient
b2=0;% coefficient
B2=0;% coefficient
b3=0;% coefficient
B3=0;% coefficient
b4=0;% coefficient
B4=0;% coefficient
b5=0;% coefficient
B5=0;% coefficient
b6=0;% coefficient
B6=0;% coefficient
b7=0;% coefficient
B7=0;% coefficient
在这一步。我想计算我的函数的值并将它们存储在矩阵中。
x=0:0.1:T; % x is the time axis
k=1:T/0.1+1;
funcation=x;
F(k)=funcation;
for x=0:0.1:T;
k=1:T/0.1+1;
a0=F(k)+a0;
end
A0=0.1*a0/T;
for x=0:0.1:T;
k=1:T/0.1+1;
b1=F(k).*sin(1.*wo.*x)+b1;
b2=F(k).*sin(2.*wo.*x)+b2;
b3=F(k).*sin(3.*wo.*x)+b3;
b4=F(k).*sin(4.*wo.*x)+b4;
b5=F(k).*sin(5.*wo.*x)+b5;
b6=F(k).*sin(6.*wo.*x)+b6;
b7=F(k).*sin(7.*wo.*x)+b7;
end
for x=0:0.1:T;
B1=0.1.*2.*b1./T.*sin(1.*wo.*x);
B2=0.1.*2.*b2./T.*sin(2.*wo.*x);
B3=0.1.*2.*b3./T.*sin(3.*wo.*x);
B4=0.1.*2.*b4./T.*sin(4.*wo.*x);
B5=0.1.*2.*b5./T.*sin(5.*wo.*x);
B6=0.1.*2.*b6./T.*sin(6.*wo.*x);
B7=0.1.*2.*b7./T.*sin(7.*wo.*x);
end
bq=B1+B2+B3+B4+B5+B6+B7;
for x=0:0.1:T;
k=1:T/0.1+1;
a1=F(k).*cos(1.*wo.*x)+a1;
a2=F(k).*cos(2.*wo.*x)+a2;
a3=F(k).*cos(3.*wo.*x)+a3;
a4=F(k).*cos(4.*wo.*x)+a4;
a5=F(k).*cos(5.*wo.*x)+a5;
a6=F(k).*cos(6.*wo.*x)+a6;
a7=F(k).*cos(7.*wo.*x)+a7;
end
for x=0:0.1:T;
A1=0.1.*2.*a1./T.*cos(1.*wo.*x);
A2=0.1.*2.*a2./T.*cos(2.*wo.*x);
A3=0.1.*2.*a3./T.*cos(3.*wo.*x);
A4=0.1.*2.*a4./T.*cos(4.*wo.*x);
A5=0.1.*2.*a5./T.*cos(5.*wo.*x);
A6=0.1.*2.*a6./T.*cos(6.*wo.*x);
A7=0.1.*2.*a7./T.*cos(7.*wo.*x);
end
aq=A1+A2+A3+A4+A5+A6+A7;
FQ=bq+aq+A0;
plot(F(k))
figure
plot(FQ)