Postgres Max Function Matlab Code