[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: handling NaN
From: |
Thomas S. Shores |
Subject: |
Re: handling NaN |
Date: |
Tue, 30 Jul 2002 18:16:51 -0500 |
Heber Farnsworth wrote:
> I'm have trouble with NaN values. I don't mind that they come up
> occasionally but I need to know how to get rid of them. I'm evaluating
> a function at various points and I need to pick the maximum point.
> Occasionally the point will be an illegal one and it's difficult to
> predict when that will happen. Obviously I don't want that point.
> However the following behavior of octave makes it difficult to get the
> point I do want.
>
> $ octave -q
> octave:1> f = [1 2 3 NaN]
> f =
>
> 1 2 3 NaN
>
> octave:2> max(f)
> ans = NaN
> octave:3> min(f)
> ans = NaN
> octave:4>
>
> If NaN is both the min and max of any vector it is contained in then how
> do I get octave to return the value I want (3 in this case)?
>
> Heber
>
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web: http://www.octave.org
> How to fund new projects: http://www.octave.org/funding.html
> Subscription information: http://www.octave.org/archive.html
> -------------------------------------------------------------
Try removing the NaNs first, e.g.,
f = [1 2 3 NaN]
max(f(!isnan(f)))
min(f(!isnan(f)))
Hope this helps
Tom Shores
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- handling NaN, Heber Farnsworth, 2002/07/30
- Re: handling NaN,
Thomas S. Shores <=