function maxX = nanmax(X)
i = find(~isnan(X));
maxX = max(X(i));