How to delete zero components in a vector in Matlab?

Posted by xiaodai on Stack Overflow See other posts from Stack Overflow or by xiaodai
Published on 2010-04-14T08:41:28Z Indexed on 2010/04/14 8:42 UTC
Read the original article Hit count: 143

Filed under:

I have a vector for example

a = [0 1 0 3]

I want to turn a into b which equals b = [1 3]

How do I perform this in general? So I have a vector with some zero components and I want to remove the zeroes and leave just the non-zero numbers.

Sorry I am new to Matlab

© Stack Overflow or respective owner

Related posts about matlab