我一直试图在matlab中显示a和bn傅里叶系数,但没有成功,我能够显示a0,因为那不是迭代的一部分。
我将非常感谢您的帮助,下面是我的代码
syms an;
syms n;
syms t;
y = sym(0);
L = 0.0005;
inc = 0.00001; % equally sample space of 100 points
an = int(3*t^2*cos(n*pi*t/L),t,-L,L)*(1/L);
bn = int(3*t^2*sin(n*pi*t/L),t,-L,L)*(1/L);
a0 = int(3*t^2,t,-L,L)*(1/L);
a0 = .5 *a0;
a0=a0
for i=1:5
y = subs(an, n, i)*cos(i*pi*t/0.0005)
z = subs(bn, n, i)*sin(i*pi*t/0.0005)
end
答案 0 :(得分:1)
如果您在问题中陈述的所有内容都是正确的,我倾向于以这种方式解决:
clc, clear all,close all
L = 0.0005;
n = 5;
an = zeros(1,n);
bn = zeros(1,n);
for i = 1:5
f1 = @(t) 3.*(t.^2).*cos(i.*pi.*t./L);
f2 = @(t) 3.*(t.^2).*sin(i.*pi.*t./L);
an(i) = quad(f1,-L,L).*(1./L);
bn(i) = quad(f2,-L,L).*(1./L);
a0 = .5.*quad(@(t) 3.*t.^2,-L,L).*(1./L);
end
我希望这会有所帮助。