Hi, I have a, b vectors and rectangular grid made of them, I write a function and obtain function values on grid. How can I find which values of 'a' and 'b' vectors correspond to particuar function value? Here's the code...
a= [1,2]
b=[3,4]
[m,n]=ndgrid(a,b)
x=[m(:),n(:)]
u = @(a, b)(a.^2+b)
g=(u(x(:,1),x(:,2)).')
Code gives me g=4,7,5,8 values.... I want to know for example which values of 'a' and 'b' created g=7 value. Thanks.

 採用された回答

madhan ravi
madhan ravi 2020 年 6 月 14 日
編集済み: madhan ravi 2020 年 6 月 14 日

0 投票

mng = [m(:), n(:), g(:)];
ab_at_g = mng(ismember(mng(:,3),7),1:2)

6 件のコメント

Ani Asoyan
Ani Asoyan 2020 年 6 月 14 日
It says : Dimensions of matrices being concatenated are not consistent.
madhan ravi
madhan ravi 2020 年 6 月 14 日
編集済み: madhan ravi 2020 年 6 月 14 日
Check once more, however j don’t see the point why you use ndgrid(...) here.
Ani Asoyan
Ani Asoyan 2020 年 6 月 14 日
It worked ! As always, Thank you so much !!
Ani Asoyan
Ani Asoyan 2020 年 6 月 14 日
I created that to obtain matrix, is there an easier way/?
madhan ravi
madhan ravi 2020 年 6 月 14 日
It would give you the same result without ndgrid(...) ;)
Ani Asoyan
Ani Asoyan 2020 年 6 月 14 日
I didn't know that, but I'll learn more about it, thank you once again !!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

質問済み:

2020 年 6 月 14 日

コメント済み:

2020 年 6 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by