Discussion:
how to remove a row containing NaN
(too old to reply)
vijay mulchandani
2012-11-19 14:55:20 UTC
Permalink
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
2012-11-19 15:43:14 UTC
Permalink
Post by vijay mulchandani
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
2012-11-19 16:38:11 UTC
Permalink
Post by Wayne King
Post by vijay mulchandani
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,:) = [];
Alternatively,

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

--
vijay mulchandani
2012-11-19 20:49:24 UTC
Permalink
Post by dpb
Post by Wayne King
Post by vijay mulchandani
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,:) = [];
Alternatively,
X(any(isnan(X),2),:)=[];
--
thanks a lot

vijay mulchandani
2012-11-19 20:48:18 UTC
Permalink
Post by Wayne King
Post by vijay mulchandani
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,:) = [];
thanks a lot
Continue reading on narkive:
Loading...