From: Natalie Sin Hwee on
"Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i1pr40$470$1(a)fred.mathworks.com>...
> "Natalie Sin Hwee " <sin.ng09(a)imperial.ac.uk> wrote in message <i1pqh4$pmj$1(a)fred.mathworks.com>...
> > Dear Mathworks users ^^
> >
> > I have a matrix of 800x2
> > 1 NaN
> > 1 NaN
> > 1 NaN
> > 1 NaN
>
> > I want to :
> >
> > if row contains NAN, remove row completely so i end up with :
> > 1 97
> > 1 47
> > 2 13
> > 2 97
> > 2 47
>
> A = [1 2;3 4; nan 5];
> A(~any(isnan(A),2),:)


Oh wow! thats a really good code!! :D so short ^^ THANKS SO MUCH!
thank youuuuuuuuuuuuu!!!
From: Nathan on
On Jul 16, 8:52 am, "Natalie Sin Hwee " <sin.n...(a)imperial.ac.uk>
wrote:
> "Sean " <sean.dewol...(a)nospamplease.umit.maine.edu> wrote in message <i1pr40$47...(a)fred.mathworks.com>...
> > "Natalie Sin Hwee " <sin.n...(a)imperial.ac.uk> wrote in message <i1pqh4$pm...(a)fred.mathworks.com>...
> > > Dear Mathworks users ^^
>
> > > I have a matrix of 800x2
> > > 1     NaN
> > > 1     NaN
> > > 1     NaN
> > > 1     NaN
>
> > > I want to :
>
> > > if row contains NAN, remove row completely so i end up with :
> > > 1     97
> > > 1     47
> > > 2     13
> > > 2     97
> > > 2     47
>
> > A = [1 2;3 4; nan 5];
> > A(~any(isnan(A),2),:)
>
> Oh wow! thats a really good code!! :D so short ^^ THANKS SO MUCH!
> thank youuuuuuuuuuuuu!!!

Another solution:
x = [nan nan;1 nan; 1 1; 1 2; 2 nan; 2 1; nan 2]
x(logical(sum(x~=x,2)),:)=[]
%%%%%%%%%%%%%%%%
x =
1 1
1 2
2 1

-Nathan
 | 
Pages: 1
Prev: image processing
Next: kmeans error message