Which row has the minimum non zero element?
2 次查看(过去 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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!