Matlab 绘图图
Matlab plotting graph
我正在尝试绘制以 phi 移动的方波的傅里叶级数,但出现此错误:
parse error near line 9 of file /home/cihad/Masaüstü/grafik.m syntax error
但是第 9 行没有任何问题
t = 0:0.001:2*pi;
A = 12;
n = 3;
p =pi/6;
fourier = 0
for n=1:2:100
fourier_an = A*(2*sin(n*p)*cos(n*pi)-2*sin(n*p)))*cos(n*t)/(n*pi); ---> line 9
fourier_bn = A*(2*cos(n*p)-2*cos(n*pi)*cos(n*p)+cos(n*p))*sin(n*t)/(n*pi);
fourier = fourier_an + fourier_bn + fourier;
end
plot(t,fourier);
有一个不应该出现的括号。尝试:
t = 0:0.001:2*pi;
A = 12;
n = 3;
p =pi/6;
fourier = 0;
for n=1:2:100
fourier_an = A*(2*sin(n*p)*cos(n*pi)-2*sin(n*p))*cos(n*t)/(n*pi);
fourier_bn = A*(2*cos(n*p)-2*cos(n*pi)*cos(n*p)+cos(n*p))*sin(n*t)/(n*pi);
fourier = fourier_an + fourier_bn + fourier;
end
plot(t,fourier);
我正在尝试绘制以 phi 移动的方波的傅里叶级数,但出现此错误:
parse error near line 9 of file /home/cihad/Masaüstü/grafik.m syntax error
但是第 9 行没有任何问题
t = 0:0.001:2*pi;
A = 12;
n = 3;
p =pi/6;
fourier = 0
for n=1:2:100
fourier_an = A*(2*sin(n*p)*cos(n*pi)-2*sin(n*p)))*cos(n*t)/(n*pi); ---> line 9
fourier_bn = A*(2*cos(n*p)-2*cos(n*pi)*cos(n*p)+cos(n*p))*sin(n*t)/(n*pi);
fourier = fourier_an + fourier_bn + fourier;
end
plot(t,fourier);
有一个不应该出现的括号。尝试:
t = 0:0.001:2*pi;
A = 12;
n = 3;
p =pi/6;
fourier = 0;
for n=1:2:100
fourier_an = A*(2*sin(n*p)*cos(n*pi)-2*sin(n*p))*cos(n*t)/(n*pi);
fourier_bn = A*(2*cos(n*p)-2*cos(n*pi)*cos(n*p)+cos(n*p))*sin(n*t)/(n*pi);
fourier = fourier_an + fourier_bn + fourier;
end
plot(t,fourier);