From: Assaf Weinstein on
Hi,

I have a vector t which contains either numerical values or NaNs. I want to take out all NaNs, ie, t=t("~NaN"); Is there a syntax to do this? (i can do this with t=t(t>=0 or t<0), i guess, but wonder if there is a direct way to obtain it..)

Thanks

asaf
From: us on
"Assaf Weinstein" <assafweinstein_remove.this(a)gmail.com> wrote in message <i0pkek$al9$1(a)fred.mathworks.com>...
> Hi,
>
> I have a vector t which contains either numerical values or NaNs. I want to take out all NaNs, ie, t=t("~NaN"); Is there a syntax to do this? (i can do this with t=t(t>=0 or t<0), i guess, but wonder if there is a direct way to obtain it..)
>
> Thanks
>
> asaf

well... you got it almost right...

one of the solutions

v=[1,nan,2,nan];
r=v(~isnan(v))
% r = 1 2
% -or-
r=v(v==v)

us
From: Assaf Weinstein on
"us " <us(a)neurol.unizh.ch> wrote in message <i0plcl$9sc$1(a)fred.mathworks.com>...
> "Assaf Weinstein" <assafweinstein_remove.this(a)gmail.com> wrote in message <i0pkek$al9$1(a)fred.mathworks.com>...
> > Hi,
> >
> > I have a vector t which contains either numerical values or NaNs. I want to take out all NaNs, ie, t=t("~NaN"); Is there a syntax to do this? (i can do this with t=t(t>=0 or t<0), i guess, but wonder if there is a direct way to obtain it..)
> >
> > Thanks
> >
> > asaf
>
> well... you got it almost right...
>
> one of the solutions
>
> v=[1,nan,2,nan];
> r=v(~isnan(v))
> % r = 1 2
> % -or-
> r=v(v==v)
>
> us

--Great, exactly what i was looking for... Thank you,

Asaf