Sigma sum error (Unrecognized variable n)

I'm trying to plot this complicated graph using matlab.

1 个评论

Well, you need to define n in the functions. You can do a for loop then you may have the summation.

请先登录,再进行评论。

回答(1 个)

Something like this:
clear ; clc ;
thesum = 0 ;
for n = 1:10
a = @(x) ((-0.07305.*x.^5+2.813.*x.^4-39.78.*x.^3+249.5.*x.^2-640.5.*x+1073).*cos(n*pi.*x/6)./6);
b = @(x) ((-0.07305.*x.^5+2.813.*x.^4-39.78.*x.^3+249.5.*x.^2-640.5.*x+1073).*sin(n*pi.*x/6)./6);
c = integral(a,-6,6) ;
d = integral(b,-6,6) ;
% e = c.*cos(n*pi.*x./6)+d.*sin(n*pi.*x./6)
thesum = thesum+c+d ;% +4796.1296
end

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

版本

R2022b

标签

提问:

2022-10-16

编辑:

2022-12-11

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by