Removing zero values from an array
443 ビュー (過去 30 日間)
古いコメントを表示
I have an n x 1 array containing values. For exmaple A =
1
0
0
2
0
3
I was wondering if it was possible to create another array except without the zero values. For example
B =
1
2
3
1 件のコメント
採用された回答
Star Strider
2015 年 5 月 14 日
Using logical indexing, you can calculate ‘B’ in one line:
B = A(A~=0)
6 件のコメント
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!