is there any command to find a maximum value of a matrix containing negative numbers also ??

답변 (4개)

No single line command, but
largest_val = (-min(x) < max(x))*(max(x)-min(x))+min(x);
is cheeky and it preserves the sign.
Jan
Jan 2013년 6월 6일
편집: Jan 2013년 6월 6일
You need the "maximum value". Then there is no reason for ABS, but you can call simply:
result = max(x)
Not sure if
max(abs())
counts as single command for you...

댓글 수: 2

thank you Mr. Andreas for the reply. But, i should not use abs in my case. Is there any alternative ??
"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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2013년 5월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by