find non zero elements put in a matrix
显示 更早的评论
i have a matrix and i want to take the row number of every non-zero element per collumn into a new matrix
回答(1 个)
Wayne King
2013-12-5
A = randi([-2 2],20,10);
idx = find(A~=0);
B = A(idx);
B contains all the nonzero elements of A, but how will you know the size of the matrix ahead of time?
类别
在 帮助中心 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!