is there any command to find a maximum value of a matrix containing negative numbers also ??
조회 수: 22 (최근 30일)
이전 댓글 표시
x =
-1 -1 -1 -1 0 -1 23 19
i need to find a maximum value for this. can i get a single line command ??
댓글 수: 0
답변 (4개)
Iain
2013년 6월 6일
No single line command, but
largest_val = (-min(x) < max(x))*(max(x)-min(x))+min(x);
is cheeky and it preserves the sign.
댓글 수: 0
Andreas Goser
2013년 5월 17일
Not sure if
max(abs())
counts as single command for you...
댓글 수: 2
Andreas Goser
2013년 5월 17일
"I should not" because of a good technical reason or just because someone told you / this is part of a homework? I can think of sorting the values first and then take the largest of the (1) and (end) values.
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!