construct anonymous function that returns the argmax of two symbolic variables
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Mischa Kim
2014년 4월 29일
편집: Mischa Kim
2014년 4월 29일
Leo, use
symMax = @(x) [max(x) find(x==max(x))]
symMax([3,4])
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!