omit zeros from matrix and have the shape of matrix
4 次查看(过去 30 天)
显示 更早的评论
A=[0,0;0,0;0,0;1,2;2,5;5,7;7,8];
I want to omit zero from this matrix. result should be
New_A=[1,2;2,5;5,7;7,8];
I use this code
A(A==0) = [];
But giving me array.
0 个评论
采纳的回答
Kevin Rawson
2019-4-14
If you are trying to get rid of rows with zeros:
A(all(A == 0, 2), :) = [];
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!