I need help to execute a triple integral

23 ビュー (過去 30 日間)
Jose Miguel Araya Martinez
Jose Miguel Araya Martinez 2022 年 9 月 28 日
im trying to do the following:
clear all
clear close
syms s r m;
fun = @(s,m,r)(r.*exp(-(s.^2/2+1.727*(m-5))))./(sqrt(r.^2-10^2));
result= integral3(fun,-inf,-(-1.85-1.013*(m-6)+1.496*log(sqrt(r.^2+31.025))),5,7.5,10,18);
final_result=result*(2*1.727)/(sqrt(2*pi)*30);
BUT matlab say me that in the intregral3 i have a invalid argument at position 3.
What am i doing wrong?

採用された回答

Torsten
Torsten 2022 年 9 月 28 日
編集済み: Torsten 2022 年 9 月 28 日
You still didn't get the point.
Look at the documentation of integral3:
q = integral3(fun,xmin,xmax,ymin,ymax,zmin,zmax) approximates the integral of the function z = fun(x,y,z) over the region xminxxmax, ymin(x)yymax(x) and zmin(x,y)zzmax(x,y)
Thus if your integration limit is a function of both other variables, it must appear as the last variable in the list ( in this case s ).
And this limit has to be a function handle, not a simple algebraic (or even symbolic) expression.
s = @(m,r) -(-1.85-1.013*(m-6)+1.496*log(sqrt(r.^2+31.025)));
fun = @(m,r,s)(r.*exp(-(s.^2/2+1.727*(m-5))))./(sqrt(r.^2-10^2));
result= integral3(fun,5,7.5,10,18,-Inf,s);
final_result=result*(2*1.727)/(sqrt(2*pi)*30)
final_result = 0.0154
  1 件のコメント
Jose Miguel Araya Martinez
Jose Miguel Araya Martinez 2022 年 9 月 29 日
Perfect! thank you so much!

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

その他の回答 (1 件)

Kevin Holly
Kevin Holly 2022 年 9 月 28 日
Your value for xmax needs to be a floating-point array.
syms s r m;
fun = @(s,m,r)(r.*exp(-(s.^2/2+1.727*(m-5))))./(sqrt(r.^2-10^2))
fun = function_handle with value:
@(s,m,r)(r.*exp(-(s.^2/2+1.727*(m-5))))./(sqrt(r.^2-10^2))
result= integral3(fun,-inf,inf,5,7.5,10,18) % I placed inf for the xmax
result = 21.4335
final_result=result*(2*1.727)/(sqrt(2*pi)*30)
final_result = 0.9845
Here I changed the value of xmax
result= integral3(fun,-inf,30,5,7.5,10,18)
result = 21.4335
result= integral3(fun,-inf,10,5,7.5,10,18)
result = 21.4335
if you place a symbolic, you will get an error as shown below.
result= integral3(fun,-inf,r,5,7.5,10,18)
Error using integral3
Invalid argument at position 3. Value must be a floating-point array.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by