How to find argument value?

조회 수: 13 (최근 30일)
Ani Asoyan
Ani Asoyan 2020년 6월 14일
댓글: Ani Asoyan 2020년 6월 14일
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일
mng = [m(:), n(:), g(:)];
ab_at_g = mng(ismember(mng(:,3),7),1:2)
  댓글 수: 6
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개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by