Delete the front zero elements from vector
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
Hello everyone
I want to delete the front zero element from vector. I receive a input vector, for example,
a=[0 0 0 2 4 0 8 9 0 3]
how can I get
a=[2 4 0 8 9 0 3]
Thank you
Famuto
댓글 수: 0
답변 (1개)
Azzi Abdelmalek
2013년 11월 26일
편집: Azzi Abdelmalek
2013년 11월 26일
a=[0 0 0 2 4 0 8 9 0 3]
a(cumsum(abs(a))==0)=[]
or
a=a(find(a~=0,1):end)
댓글 수: 1
chi ha ko
2013년 11월 26일
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!