Removing zero values from an array
조회 수: 517 (최근 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!