Friday, June 29, 2012

How to remove zeros from a vector?

Imagine you have the following vector and you want to remove the zero values

 X=[6 8 0 4 6 8 9 0 9 7 7 ]

X =

     6     8     0     4     6     8     9     0     9     7     7


The following command will remove the zero values

 X(all(X==0,1))=[]

X =

     6     8     4     6     8     9     9     7     7

No comments:

Post a Comment

Please ask if anything is not clear enough..........