フィルターのクリア

Return the column(s) indices with minimum value which is not zero.

3 ビュー (過去 30 日間)
Rishi Balasubramanian
Rishi Balasubramanian 2020 年 12 月 20 日
回答済み: Walter Roberson 2020 年 12 月 20 日
Consider a matrix H = 1x30.
The data in those elements are numbers 0, 1, 2, ......, n
I wanna be able select the column(s) with the values from 1.
If H has a '0', then columns having '1' must be returned.
If H has a '0', and has no 1s, then columns having '2' must be returned.
If H has a '0', and has no 1s and 2s, then columns having '3' must be returned.... and so on.
It should be able to return all the columns with a minimum value in it, where the minimum value cannot be zero. But it is any available minimum value after 0.
How do i achieve this?

採用された回答

Walter Roberson
Walter Roberson 2020 年 12 月 20 日
any(H==min(H(H~=0)),1)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by