nan problem

1 次查看(过去 30 天)
x
x 2011-10-8
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
A very vague question. I guess the answer is: yes.
x = [1, NaN, 3];
x(isnan(x)) = [];
  6 个评论
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))

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by