nan problem

any ways to remove NAN in the final results

댓글 수: 1

Walter Roberson
Walter Roberson 2011년 10월 9일
Duplicate is at http://www.mathworks.com/matlabcentral/answers/16221-nan-value

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

답변 (1개)

Jan
Jan 2011년 10월 8일

0 개 추천

A very vague question. I guess the answer is: yes.
x = [1, NaN, 3];
x(isnan(x)) = [];

댓글 수: 6

x
x 2011년 10월 8일
when this is done then ahat will be the response sir?nan values wont be displayed..but this may affect the performance ah
x
x 2011년 10월 8일
what does 1,3 means
Wayne King
Wayne King 2011년 10월 8일
Jan is giving you an example by creating a vector,x, with one NaN. Then he is using isnan() to find the element of x that is a NaN and removing it.
x
x 2011년 10월 8일
FOR A 9 BY 9 MATRIX I AM GETTING NAN value..i am getting complex term as 9by9 matrix so i used normalization but for few patches i come across 0/0 so the NAN returns..what can i do for this sir
Jan
Jan 2011년 10월 8일
@x: An explicite example would be much easier to understand.
If your results contain some 0/0==NaN values, it is your turn to define what should happen in this case. It is impossible for us to guess, what a good replacement could be, because this depends on your problem.
Perhaps: x(isnan(x)) = 0, or x(isnan(x)) = -1000, or whatever.
If you plot the results NaN's are often treated very handy, because they are not drawn. See:
plot([1:10, NaN, 11:16]);
Andrei Bobrov
Andrei Bobrov 2011년 10월 8일
Hi Jan!
x = x(~isnan(x))

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

x
x
2011년 10월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by