From: Kevin on
Hi guys, I'm very new with MATLAB and need help solving a problem,

Lets say I have a vector x = [1,0,2,0,3,0,4,0,5]
How can I truncate/get rid of the value 0 so it does not show up?
I want it to look like this: [1,2,3,4,5]

This is a pretty simple question but I can't find the answer anywhere! Any help would be very appreciated!
Thanks.
From: us on
"Kevin " <x1nner(a)hotmailremovethis.com> wrote in message <hohr2s$3oe$1(a)fred.mathworks.com>...
> Hi guys, I'm very new with MATLAB and need help solving a problem,
>
> Lets say I have a vector x = [1,0,2,0,3,0,4,0,5]
> How can I truncate/get rid of the value 0 so it does not show up?
> I want it to look like this: [1,2,3,4,5]
>
> This is a pretty simple question but I can't find the answer anywhere! Any help would be very appreciated!
> Thanks.

one of the solutions

x=[1,0,2,0];
x=x(x~=0)
% x = 1 2

us
From: Kevin on
"us " <us(a)neurol.unizh.ch> wrote in message <hohrli$bvc$1(a)fred.mathworks.com>...
> "Kevin " <x1nner(a)hotmailremovethis.com> wrote in message <hohr2s$3oe$1(a)fred.mathworks.com>...
> > Hi guys, I'm very new with MATLAB and need help solving a problem,
> >
> > Lets say I have a vector x = [1,0,2,0,3,0,4,0,5]
> > How can I truncate/get rid of the value 0 so it does not show up?
> > I want it to look like this: [1,2,3,4,5]
> >
> > This is a pretty simple question but I can't find the answer anywhere! Any help would be very appreciated!
> > Thanks.
>
> one of the solutions
>
> x=[1,0,2,0];
> x=x(x~=0)
> % x = 1 2
>
> us

Thanks! I knew this was a quick fix, I was just a little stumped :)