How to remove zero values from vector?
이전 댓글 표시
Hi,
Let's say I have vector something like:
q = [0 0 0 2 4 10 9 5 0 0 0 8 9]
I want it to be something like:
q = {0 0 0 2 4 10 9 5 8 9]
How can I choose to remove the zero values but without removing the first three zeroes?
Thank you.
채택된 답변
추가 답변 (2개)
belairaway
2017년 5월 9일
편집: belairaway
2017년 5월 9일
1 개 추천
I think that using the built-in function nonzeros is better
Azzi Abdelmalek
2013년 6월 14일
편집: Azzi Abdelmalek
2013년 6월 14일
q = [0 0 0 2 4 10 9 5 0 0 0 8 9];
out=[q(1:find(q~=0,1)) q(q~=0)]
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!