필터 지우기
필터 지우기

How to find a maximum number not considered minus sign?

조회 수: 15 (최근 30일)
Jothi
Jothi 2014년 7월 17일
댓글: Bruno Luong 2021년 3월 28일
Sir,
I want find the maximum number in the given array.
But, I am not considered negative sign.
for example, a=[4, 3, -8],
output is = -8. Because 8 is the maximum number.
how I get this output.
thank you.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 7월 17일
a = [4, 3, -8];
[~,ii] = max(abs(a));
out = a(ii);
  댓글 수: 2
Poorva
Poorva 2021년 3월 28일
Sir, how to do the same in a matrix
Bruno Luong
Bruno Luong 2021년 3월 28일
The same command should work on matrix to.

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

추가 답변 (1개)

Matz Johansson Bergström
Matz Johansson Bergström 2014년 7월 17일
It sounds like you want to find the max absolute value of a vector. This can be accomplished simply by taking the absolute value and remember the index to that value and picking it out:
a = [1,4,5,-8,3];
[val, ind] = max(abs(a));
a(ind)
  댓글 수: 2
Matz Johansson Bergström
Matz Johansson Bergström 2014년 7월 17일
Ah, Andrei beat me to it ;-)
Jothi
Jothi 2014년 7월 17일
i accept this answer also.
thank you sir.

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

카테고리

Help CenterFile Exchange에서 Wavelet Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by