What's wrong with this integral?

26 ビュー (過去 30 日間)
Hugo
Hugo 2015 年 7 月 10 日
編集済み: Walter Roberson 2015 年 7 月 11 日
I get an error message typing this:
integral(@(z)(sin(z)*exp(1i*z)),0, 1)
Here is the error message:
Error using *
Inner matrix dimensions must agree.
Error in @(z)(sin(z)*exp(1i*z))
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
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);

採用された回答

Star Strider
Star Strider 2015 年 7 月 11 日
You likely need to vectorise it:
integral(@(z)(sin(z).*exp(1i*z)),0, 1)
Note the vectorised multiplication (.*). See Array vs. Matrix Operations for a full discussion.

その他の回答 (1 件)

Roger Stafford
Roger Stafford 2015 年 7 月 11 日
You must define your integrand function so that it will accept a vector input. In this case that means put a dot in the multiplication symbol:
integral(@(z)(sin(z).*exp(1i*z)),0, 1)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by