Finding and removing NaN values in a matrix

조회 수: 3 (최근 30일)
Nancy
Nancy 2011년 9월 26일
댓글: Walter Roberson 2017년 8월 3일
Hi Guys,
I am dealing with matrices of the size 1268*100. I wish to eliminate certain rows from this matrix. I do certain operations to get integer values for the rows that I want to keep and NaN value for the ones I dont. How can I get the rows that have NaN values and use these numbers to eliminate the rows that I dont want in my main matrix.
Eg. if my column matrix has the following values= [1 2 3 NaN 3 4 NaN 5 7 NaN]
So I will need to eliminate rows 4 7 and 10 in my main matrix.
How do I go about doing that.
Thanks, Nancy

채택된 답변

Walter Roberson
Walter Roberson 2011년 9월 26일
Is it only necessary to refer to column 1, or are there other columns that might have nans that signal removal ?
If column 1 alone is enough, then you can use
values(isnan(values(:,1)),:) = [];
  댓글 수: 5
Ahmed
Ahmed 2017년 8월 3일
Try this
f(isnan(f))=[];
Walter Roberson
Walter Roberson 2017년 8월 3일
Ahmed, that has the same problems I described for Shubham Maurya's suggestion.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by