Arg max of a function
4 次查看(过去 30 天)
显示 更早的评论
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
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).
回答(1 个)
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!