How do I evaluate this triple integral using the function integral3

xmin= @(y) y.^2
xmax= @(y) y.^0.5
ymin=0
ymax=1
zmin=0
zmax=@(x,y,z) x+y+36
h = @(y,x,z) 1 %dz dx dy
answer3 = integral3(h, ymin, ymax , xmin , xmax , zmin, zmax);
answer3 = vpa(answer3,8)
%%why doesnt this code work, can someone help me

 採用された回答

Walter Roberson
Walter Roberson 2020 年 11 月 10 日
xmin= @(y) y.^2
xmin = function_handle with value:
@(y)y.^2
xmax= @(y) y.^0.5
xmax = function_handle with value:
@(y)y.^0.5
ymin=0
ymin = 0
ymax=1
ymax = 1
zmin=0
zmin = 0
zmax=@(x,y,z) x+y+36
zmax = function_handle with value:
@(x,y,z)x+y+36
h = @(y,x,z) ones(size(y)) %dz dx dy
h = function_handle with value:
@(y,x,z)ones(size(y))
answer3 = integral3(h, ymin, ymax , xmin , xmax , zmin, zmax);
answer3 = vpa(answer3,8)
answer3 = 
12.3

3 件のコメント

bob
bob 2020 年 11 月 10 日
what exactly does the ones(size(y)) does? (in context for the integral) I haven't used it
Walter Roberson
Walter Roberson 2020 年 11 月 10 日
The integral() family of functions call the given function passing in vectors or arrays of values, expecting the same size of output, using element-wise computations.
So your h(y,x,z) was being called with non-scalar y, x, z, but you were returning the scalar constant 1 no matter what the input size was. You need to return one of those 1's for every input element.
bob
bob 2020 年 11 月 10 日
oh i see, I understand it now. Thank you

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCOM Component Integration についてさらに検索

質問済み:

bob
2020 年 11 月 10 日

コメント済み:

bob
2020 年 11 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by