remove rows with all zeros

 采纳的回答

b = a(any(a,2),:);

5 个评论

thanks Walter
walter cheers mate
Note: the above code treats nan values the same as zero values, so for example the row [0 nan nan] would also be removed. If that is not acceptable, then
b = a(any(a ~= 0,2),:);
Hi Walter,
Would you please explain this line?
b = a(any(a,2),:);

请先登录,再进行评论。

更多回答(1 个)

Geoff
Geoff 2012-6-6

0 个投票

Search facility on Answers shows this question is asked a lot... Here's one of the more recent.

类别

帮助中心File Exchange 中查找有关 Matrix Indexing 的更多信息

产品

标签

Community Treasure Hunt

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

Start Hunting!

Translated by