필터 지우기
필터 지우기

why i get this error when using integral?

조회 수: 14 (최근 30일)
ocsse
ocsse 2018년 3월 27일
편집: Kedar Bahulkar 2021년 3월 20일
Error using integralCalc/finalInputChecks (line 515) Output of the function must be the same size as the input. If FUN is an array-valued integrand, set the 'ArrayValued' option to true.
Error in integralCalc/iterateScalarValued (line 315) finalInputChecks(x,fx);
Error in integralCalc/vadapt (line 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75) [q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88) Q = integralCalc(fun,a,b,opstruct);
T = 5;
t = linspace(0,5*T,5*500+1); % 5 cycles
t = t(1:end-1);
n = (1:3).';
a0 = (1/T) * integral(@(t) exp((10 - t) / 2), 0, 5);
an = (2/T) * integral(@(t) exp((10 - t) / 2).*cos(2*pi*f0*n*t), 0, 5);
the error occurs when computing an
even when i try the time vector without multiplying by 5. the same problem occurs

채택된 답변

Torsten
Torsten 2018년 3월 27일
The solution is given in the error message:
an = (2/T) * integral(@(t) exp((10 - t) / 2).*cos(2*pi*f0*n*t), 0, T, 'ArrayValued',true);
By the way: You don't need to specify the t-vector ; "integral" will use ist own spatial gridding.
Best wishes
Torsten.
  댓글 수: 1
Kedar Bahulkar
Kedar Bahulkar 2021년 3월 20일
편집: Kedar Bahulkar 2021년 3월 20일
Hello, Thankyou @Torsten. I had the same error and it got solved by your answer. I want to know, whether it is necessary to add
...'ArrayValued',true)
when performing numerical integration always?
Thank you
Kedar

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Bartlett에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by