function [min_val, max_val] = array_extremes(array) % % Find the minimum and maximum values in an array of numbers. % % Arguments: % % array (input) 1-D array of numbers % % min_val (output) the minimum value % % max_val (output) the maximum value % % Check the dimensions of the 'array' argument. % We expect a simple 1-D array of numbers, in which case % num_rows should be 1 % num_cols will be the number of values in the array % % If the given 'array' isn't a simple 1-D array, print an error % message and quit. [num_rows, num_cols] = size(array); if (num_rows ~= 1) error('array_extremes: array must be one-dimensional'); end min_val = array_min(array); max_val = array_max(array);