Max and min keeping NaNs

버전 1.0.0.0 (2.22 KB) 작성자: David Young
The max and min functions ignore NaN values. These functions keep them like arithmetic functions do.
다운로드 수: 419
업데이트 날짜: 2013/12/12

라이선스 보기

Most arithmetic operations propagate NaN values, but max and min ignore them. For example 3+NaN and sum([3 NaN]) return NaN, but max(3, NaN) and max([3 NaN]) return 3.

Sometimes it is useful for max and min to behave like other arithmetic functions. For example, if you wish to set all the negative values in a vector to 0, using max(v, 0), you may not wish also to remove NaNs representing missing data points.

maxNan and minNan are functions which can be used in place of max and min but which return a NaN wherever a comparison with a NaN took place. The various combinations of arguments and results accepted by by max/min are also accepted by maxNan/minNan.

Example:

max([1 2 3; 4 NaN 0])

returns [4 2 3] but

maxNan([1 2 3; 4 NaN 0])

returns [4 NaN 3].

(Note that nanmax and nanmin in the statistics toolbox are the same as max and min.)

인용 양식

David Young (2024). Max and min keeping NaNs (https://www.mathworks.com/matlabcentral/fileexchange/44702-max-and-min-keeping-nans), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2013b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 NaNs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0