From: roya olyazadeh on
I wan to remove zero elements from my matrix like this :

A = [ 1 0 0 0 5 6 0 0 0 10 ]
then :
A = [ 1 5 6 10 ]
From: James Tursa on
"roya olyazadeh" <roya2543(a)gmail.com> wrote in message <hsvt3d$8cs$1(a)fred.mathworks.com>...
> I wan to remove zero elements from my matrix like this :
>
> A = [ 1 0 0 0 5 6 0 0 0 10 ]
> then :
> A = [ 1 5 6 10 ]

A(A~=0)

James Tursa
From: us on
"roya olyazadeh" <roya2543(a)gmail.com> wrote in message <hsvt3d$8cs$1(a)fred.mathworks.com>...
> I wan to remove zero elements from my matrix like this :
>
> A = [ 1 0 0 0 5 6 0 0 0 10 ]
> then :
> A = [ 1 5 6 10 ]

one of the many other solutions

v=[1,0,0,2,nan,3]
v(v==0)=[]

us
From: Matt J on


nonzeros(A);