フィルターのクリア

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 Center および File ExchangeWavelet Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by