1
function [s,index] = nanmax(x,orient)
3
//This function gives for a real or a numerical matrix x a his largest
4
//element m (but ignoring the NANs).
6
//For x, a numerical vector or matrix, m=nanmax(x) returns in scalar m
7
//the largest element of x (ignoring the NANs). The form [m,index] =
8
//nanmax(x,orient) gives in addition of the value of the largest element
9
//of x (ignoring the NANs) in scalar m, and the index of this element
10
//in x, as a 2-vector.
12
//m=nanmax(x,'r') gives in the 1xsize(x,2) matrix m the largest elements
13
//(ignoring the NANs) of each column of x. If the form
14
//[m,index]=nanmax(x,'r') is used, the elements of the 1xsize(x,2)
15
//matrix index are the indexes of the largest elements (ignoring the
16
//NANs) of each column of x in the corresponding column.
18
//m=nanmax(x,'c') gives in the size(x,2)x1 matrix m the largest elements
19
//(ignoring the NANs) of each row of x. If the form
20
//[m,index]=nanmax(x,'c') is used, the elements of the size(x,2)x1
21
//matrix index are the indexes of the largest elements (ignoring the
22
//NANs) of each row of x in the corresponding row.
24
//author: carlos klimann
29
if argn(2)==1 then orient='*',end
30
if orient==1 then orient='r',end
31
if orient==2 then orient='c',end
32
if x==[]|(size(x,'*')==1&isnan(x)) then s=[],index=[],return,end
35
[s,index]=max(x,orient)
36
s(find(and(isn,orient)))=%nan