フィルターのクリア

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 Center および File ExchangeBartlett についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by