Sigma sum error (Unrecognized variable n)

조회 수: 1 (최근 30일)
Taekyung
Taekyung 2022년 10월 16일
편집: Taekyung 2022년 12월 11일
I'm trying to plot this complicated graph using matlab.
  댓글 수: 1
Ghazwan
Ghazwan 2022년 10월 16일
Well, you need to define n in the functions. You can do a for loop then you may have the summation.

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2022년 10월 16일
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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by