function a=gmax(b);
% g=find(b(:)~=NaN);
% a=max(b(g));

%%%%% Modified by jpx %%%%%
g=isnan(b(:));
g=find(~g);
a=max(b(g));
%%%%% Modified by jpx %%%%%
