Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to remove a row containing NaN

19 views
Skip to first unread message

vijay mulchandani

unread,
Nov 19, 2012, 9:55:20 AM11/19/12
to
i have a velocity matrix of 98x124 and i want to remove the complete row where the velocity value is NaN, so that afterwards i can take the mean of the matrix. How can i delete it?

Wayne King

unread,
Nov 19, 2012, 10:43:14 AM11/19/12
to
"vijay mulchandani" <va...@tu-clausthal.de> wrote in message <k8dh8o$rka$1...@newscl01ah.mathworks.com>...
> i have a velocity matrix of 98x124 and i want to remove the complete row where the velocity value is NaN, so that afterwards i can take the mean of the matrix. How can i delete it?

X = randn(98,124);
X(4,2) = NaN;
[I,J] = find(isnan(X));
X(I,:) = [];

dpb

unread,
Nov 19, 2012, 11:38:11 AM11/19/12
to
Alternatively,

X(any(isnan(X),2),:)=[];

--


vijay mulchandani

unread,
Nov 19, 2012, 3:48:18 PM11/19/12
to
"Wayne King" wrote in message <k8dk2i$9ed$1...@newscl01ah.mathworks.com>...
thanks a lot

vijay mulchandani

unread,
Nov 19, 2012, 3:49:24 PM11/19/12
to
dpb <no...@non.net> wrote in message <k8dnb9$pge$1...@speranza.aioe.org>...
thanks a lot
0 new messages