function theMax = myMax(v) % myMax return maximum value in a vector % % consumes: v, a vector % produces: theMax, a scalar, the maximum value in v % % Example: % >> myMax([3 5 6 2]) % ans = % 6 % >> myMax([]) % ans = % [] % % P. Conrad for CISC106, sect 99, 10/22/2007 if (length(v) == 0) theMax = []; else theMax = v(1); for i=2:length(v) if (v(i) > theMax) theMax = v(i); end; % if end; % for end % if return; end % function