is there any command to find a maximum value of a matrix containing negative numbers also ??
27 ビュー (過去 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!