is there any command to find a maximum value of a matrix containing negative numbers also ??
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (4)
Iain
am 6 Jun. 2013
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 Kommentare
Andreas Goser
am 17 Mai 2013
Not sure if
max(abs())
counts as single command for you...
2 Kommentare
Andreas Goser
am 17 Mai 2013
"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.
Siehe auch
Kategorien
Mehr zu Logical 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!