Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is the difference between `min` and `nanmin`; `max` and `nanmax` in Matlab?

Tags:

matlab

Matlab describes nanmin and nanmax like this:

NANMIN Minimum value, ignoring NaNs.

NANMAX Maximum value, ignoring NaNs.

But in fact, min and max ignore NaNs too.

Which should I use then?

According to my tests, nanmin and nanmax are faster. Is it always like this?

like image 854
Oriol Avatar asked Oct 31 '13 00:10

Oriol


1 Answers

nanmin just calls min:

[varargout{1:nargout}]=min(varargin{:});

Similarly for nanmax. That's it!

In some past release, the built-in min and max were updated with the same functionality, ignoring NaN, and the toolboxes just started pointing to them instead of maintaining their own implementations. Just use max and min, unless you are working on special types that might have their own implementations of these functions.

like image 104
chappjc Avatar answered Nov 09 '22 09:11

chappjc