【问题标题】:Fourier coefficients using matlab numerical integration使用matlab数值积分的傅立叶系数
【发布时间】:2013-01-31 19:27:11
【问题描述】:

我一直试图在 matlab 中显示 an 和 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

【问题讨论】:

  • matlab 检索到的错误是什么?
  • 您能给我们提供一份预期结果的清单吗?

标签: fft matlab numerical-integration


【解决方案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

我希望这会有所帮助。

【讨论】:

  • 谢谢......这看起来像我需要的,结果似乎接近我的预期,我也编辑了原始代码,因为我忘记包含相同的样本空间点。
  • 预期结果:我希望能够改变相同的样本空间并使用matlab数值计算计算百分比误差值。
  • 如果答案符合您的期望,您可能会考虑证明它是正确的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-03-25
  • 1970-01-01
  • 1970-01-01
  • 2019-12-28
  • 2012-05-18
  • 2016-07-13
  • 1970-01-01
相关资源
最近更新 更多