Double Integration error using /

2 ビュー (過去 30 日間)
Shanmakha Mangadahalli Siddaramu
Shanmakha Mangadahalli Siddaramu 2021 年 12 月 1 日
Hi,
I am trying to do double integration. But I am getting following error.
inte = @(y,x) (cos(x).^2)/(1 + alpha/(cos(x)*sqrt(1 - 1/y.^2))).^2*(1/y.^3 - 1/y.^5);
integral2(inte,1,Inf,0,pi/2)
Error: Error using /
Matrix dimensions must agree

採用された回答

Chunru
Chunru 2021 年 12 月 1 日
Keep in mind that the function should be defined for vector arguments x and y. Therefore some * and / should be changed to .* and ./.
alpha = 1;
inte = @(y,x) (cos(x).^2)./(1 + alpha./(cos(x).*sqrt(1 - 1./y.^2))).^2 .*(1./y.^3 - 1./y.^5);
integral2(inte,1,Inf,0,pi/2)
ans = 0.0319
  1 件のコメント
Shanmakha Mangadahalli Siddaramu
Shanmakha Mangadahalli Siddaramu 2021 年 12 月 1 日
thanks :)

サインインしてコメントする。

その他の回答 (1 件)

Mike Croucher
Mike Croucher 2021 年 12 月 1 日
You need to vectorise your equation
alpha = 1.0;
inte = @(y,x) (cos(x).^2)./(1 + alpha./(cos(x).*sqrt(1 - 1./y.^2))).^2.*(1./y.^3 - 1./y.^5);
integral2(inte,1,Inf,0,pi/2)
ans =
0.0319
You didn't define alpha so I took a guess.
Hope this helps,
Mike
  1 件のコメント
Shanmakha Mangadahalli Siddaramu
Shanmakha Mangadahalli Siddaramu 2021 年 12 月 1 日
Thanks :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by