Arg max of a function

4 visualizaciones (últimos 30 días)
Tina poddar
Tina poddar el 21 de Nov. de 2020
Comentada: Tina poddar el 28 de Nov. de 2020
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 comentarios
Bruno Luong
Bruno Luong el 22 de Nov. de 2020
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 el 28 de Nov. de 2020
Thank you

Iniciar sesión para comentar.

Respuestas (1)

Steven Lord
Steven Lord el 21 de Nov. de 2020
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 comentario
Tina poddar
Tina poddar el 22 de Nov. de 2020
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

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by