Arg max of a function

조회 수: 10 (최근 30일)
Tina poddar
Tina poddar 2020년 11월 21일
댓글: Tina poddar 2020년 11월 28일
I have a doubt regarding finding arg max of a function m = x+y?
function m = equation(x,y)
k = x+y;
[max_value, max_ind] = max(k);
m = k(max_ind);
end
Thank you in advance
  댓글 수: 6
Bruno Luong
Bruno Luong 2020년 11월 22일
No, argmax is the argument at which the function (in your case the array result of plus) is maximized (hence the name ARGMAX)
You should return "max_ind" or "sub2ind(size(k),max_ind)" rather than k(max_ind) (which is btw equal to max_value).
Tina poddar
Tina poddar 2020년 11월 28일
Thank you

댓글을 달려면 로그인하십시오.

답변 (1개)

Steven Lord
Steven Lord 2020년 11월 21일
The operator + does not and cannot return two output arguments. Nor can its functional form, plus.
As a hint, take a look at the examples on the documentation page for the max function and see if you can adapt one of those to your needs.
  댓글 수: 1
Tina poddar
Tina poddar 2020년 11월 22일
Thank you for response
However though i have made changes i am not able to get matrices of max values for which the function has max value that is arg max.
Can you please help

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by