find non zero elements put in a matrix
2 ビュー (過去 30 日間)
古いコメントを表示
i have a matrix and i want to take the row number of every non-zero element per collumn into a new matrix
0 件のコメント
回答 (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?
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!