How to find a double integral

1 回表示 (過去 30 日間)
Hirak
Hirak 2019 年 5 月 19 日
コメント済み: Star Strider 2019 年 5 月 22 日
I need to integrate the function wrt theta and phi. How to do it? m,n, p are constants.
f=m*p*cos(theta)^3*sin(phi)^2 - n*p*cos(phi)^2*cos(theta)^3 - m*n*cos(theta)*sin(phi)^2*sin(theta)^2 + m*n*cos(phi)*cos(theta)*sin(phi)*sin(theta)^2

採用された回答

Star Strider
Star Strider 2019 年 5 月 19 日
It is best to vectorize your function using element-wise operations, then create it as a function of the two variables, then use integral2 to numerically integrate it:
m = 3;
n = 5;
p = 7;
f = @(theta,phi) m*p*cos(theta).^3.*sin(phi).^2 - n*p*cos(phi).^2.*cos(theta).^3 - m*n*cos(theta).*sin(phi).^2.*sin(theta).^2 + m*n*cos(phi).*cos(theta).*sin(phi).*sin(theta).^2;
f_int = integral2(f, 0, 2*pi, 0, 2*pi)
I created values for the constants to test the code.

その他の回答 (1 件)

Hirak
Hirak 2019 年 5 月 22 日
Thanks to you two....
  1 件のコメント
Star Strider
Star Strider 2019 年 5 月 22 日
As always, our pleasure.

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

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by