function  [Min_value, Max_value, Num_values] = Min_Max_N(Matrix)
%---------------------------------------------------------------
%       USAGE: [Min_value Max_value Num_values] = Min_Max_N(Matrix)
%
%      AUTHOR: Col David S. Gibson       DATE: 21 Sep 04
%    MODIFIED: Dr. Wayne Brown           DATE: 16 Aug 05
%
% DESCRIPTION: This function returns minimum, maximum, and 
%              number of the values in the input matrix which
%              may be a vector or 2-D array (but not 3-D or above).
%
%      INPUTS: Matrix - a vector or 2-D array of numeric values
%
%     OUTPUTS: Min_value  - the minimum value in the matrix
%              Max_value  - the maximum value in the matrix
%              Num_values - the number of values in the matrix
%
%  REFERENCES: None
%---------------------------------------------------------------

% get size of matrix and set n to the number of elements

[Rows Cols] = size(Matrix);

Num_values = Rows * Cols;

% get min and max values of matrix which are:
%   scalars if matrix is a vector
%   vectors if matrix is a 2-D array

Min_value = min(Matrix);
Max_value = max(Matrix);

% if matrix is a 2-D array, then get the min and max values
% by extracting them from the min and max vectors of matrix

if (Rows > 1) || (Cols > 1)
    Min_value = min(Min_value);
    Max_value = max(Max_value);
end

end % function Min_Max_N