フィルターのクリア

Find minimum in matrice

1 回表示 (過去 30 日間)
Miguel Albuquerque
Miguel Albuquerque 2022 年 7 月 16 日
回答済み: patrick1704 2022 年 7 月 16 日
Hey guys, thanks in advance
I have this matrix, that always has zeros, but also other values. I want to find the minimum of the matrix, besides the zeros, how can I do that?

採用された回答

patrick1704
patrick1704 2022 年 7 月 16 日
Hi,
If you only care about the value and not the index, you could do something like this:
min(R1_matrix(R1_matrix ~= 0))
If you care about the index you could do something like:
R1_matrix(R1_matrix == 0) = inf;
min(R1_matrix)

その他の回答 (1 件)

KSSV
KSSV 2022 年 7 月 16 日
編集済み: KSSV 2022 年 7 月 16 日
Let A be your matrix.
A(A==0) = NaN ; % replace 0's with NaNs
[val,idx] = min(A)
Or, use:
val = min(A(A>0))

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by