How to define function include others functions in matlab

Assume I have 2 complicated function X(u) and Y(v). How to define R(X,Y) function, then I can get integral of R(u,v)?
For example
X(u) = 1-u
Y(v) = 1-v
R(u,v) = sqrt(X^2+Y^2)

 採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 11 月 15 日
X = @(u) 1-u;
Y = @(v) 1-v;
R = @(u,v) sqrt(X(u).^2+Y(v).^2);
%Integrate R w.r.t u from 0 to 1
%and w.r.t v from 1 to 2
integral2(R, 0, 1, 1, 2)
ans = 0.7652

2 件のコメント

binh23294
binh23294 2023 年 11 月 15 日
Thanks a lot!
Dyuman Joshi
Dyuman Joshi 2023 年 11 月 15 日
You are welcome!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2023b

質問済み:

2023 年 11 月 15 日

コメント済み:

2023 年 11 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by