construct anonymous function that returns the argmax of two symbolic variables
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Leo Simon
am 29 Apr. 2014
Beantwortet: Leo Simon
am 29 Apr. 2014
Hi, I'd like to construct an anonymous function that returns the argmax of two symbolic variables, e.g.,
syms x y
symMax = @(x,y) max(x,y)
symMax(3,4)
returns
4,
but I don't know how to persuade the anonymous function to return the second argument of max, which is 2.
Parenthetically, I can't do this even when x,y are regular variables, but in that case I have more options to work with.
Thanks very much for any advice.
Leo
0 Kommentare
Akzeptierte Antwort
Mischa Kim
am 29 Apr. 2014
Bearbeitet: Mischa Kim
am 29 Apr. 2014
Leo, use
symMax = @(x) [max(x) find(x==max(x))]
symMax([3,4])
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!