Cutting rows and columns from a matrix
显示 更早的评论
If A = [0,0,0,0;0,0,0,0;0,0,1,1;0,0,1,1], how can i cut out the null comumns and rows to acheive B = [1,1;1,1]
采纳的回答
更多回答(1 个)
Andrei Bobrov
2011-5-20
B = zeros(sum(any(A,2)),sum(any(A)));
B(:)=A(A~=0);
类别
在 帮助中心 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!