help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: handling NaN


From: John W. Eaton
Subject: Re: handling NaN
Date: Mon, 5 Aug 2002 22:47:14 -0500

On  6-Aug-2002, Schloegl Alois <address@hidden> wrote:

| | 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
| 
| But without using loops, is there also a way to do this along a
| particular dimension of a matrix when each column/row/etc. may have a
| different number of NaNs?
| 
| jwe
| 
| 
| ------------------------------------------------------
| 
| John, 
| 
| I guess this would do it:
| 
| f(isnan(f))=-inf;
| max(f);
| max(f');

Right, Paul also pointed out to me in email that the nanmax and
nanmean functions in octave-forge use this method.

Thanks,

jwe



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]