How do I find the non-zero column in a matrix and create it as a single matrix?
Show older comments
i.e from A =
[0 0 0 0 0 0 2 0 0]
0 0 0 0 0 0 5 0 0
create B=
[2]
5
Accepted Answer
More Answers (1)
tmp = A';
B = tmp(tmp > 0);
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!