Cutting rows and columns from a matrix
1 次查看(过去 30 天)
显示 更早的评论
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]
0 个评论
采纳的回答
Jos (10584)
2011-2-10
See ANY (or ALL). You need a two step approach:
A = [1 0 1 0 ; 1 0 1 0 ; 0 0 0 0]
B = A(any(A,2),:) ; % remove null rows
B = B(:,any(A,1)) % remove null columns
0 个评论
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!