Which row has the minimum non zero element?
1 回表示 (過去 30 日間)
古いコメントを表示
Hello i have a matrix and i want to find which is the row with minimum nonzeros elements.I dont want the number of non zeros,but i want to know which is the row.
0 件のコメント
採用された回答
Star Strider
2015 年 3 月 21 日
I’m not certain what you mean by ‘minimum nonzeros elements’. This takes the row sum of the rows with nonzero elements and finds the row with the smallest row sum:
M = randi(51, 20, 5)-1;
[r0,~] = find(M == 0);
Mnz = M(setdiff([1:size(M,1)],r0),:);
[Mu, ix] = sort(sum(M,2));
Row_min_nz = is(x); % Row With Minimum Row Sum
その他の回答 (2 件)
Konstantinos Sofos
2015 年 3 月 21 日
a = [2,2,3;0,2,5;1 2 3]
[row,column]=find(a==min(min(a(a>0))))
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!