[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: handling NaN
From: |
Ben Harris |
Subject: |
Re: handling NaN |
Date: |
Wed, 31 Jul 2002 12:38:00 -0500 |
Here is how I would solve this problem--one extra line of code, MATLAB
compatible too:
octave:14> f = [1 2 3 NaN]
f =
1 2 3 NaN
octave:15> idx = find(~isnan(f));
octave:16> max(f(idx))
ans = 3
Regards,
Ben Harris
Heber Farnsworth
<address@hidden To: address@hidden
wustl.edu> cc:
Subject: handling NaN
07/30/2002 04:57
PM
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
-------------------------------------------------------------
-------------------------------------------------------------
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
-------------------------------------------------------------
- Re: handling NaN,
Ben Harris <=