function maedispsubarray(array, top, left, bottom, right, format_)
%MAEDISPSUBARRAY  Print the specified subarray of the input array.
%   Used by the Array Editor.
%   ARRAY is a 2D numeric array.
%   Print the specified subarray, with each element displayed on a line by
%      itself. 
%   FORMAT_ is an optional format string (for example, 'long e') that is passed
%      to the FORMAT command to set the output format.  After the subarray
%      has been printed, the output format is restored to whatever it was
%      previously.

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.4 $  $Date: 1998/05/28 19:51:14 $

if nargin < 5
    error('Too few input arguments.');
end

% if the caller didn't specify format_, then set that arg to [] so we can
% pass format_ to the subfunction without causing an error
if ~exist('format_', 'var')
    format_ = [];
end

% if the user specified a numeric format, then use it
oldFormat = [];
if ~isempty(format_)
    oldFormat = get(0, 'Format');
    eval(['format ' format_]);    % apply user's format
end

% display the subarray, one element per line
temp = array(top:bottom, left:right);
if issparse(temp)
    temp = full(temp);
end
disp(temp(:));

% restore original numeric format if necessary
if ~isempty(oldFormat)
    set(0, 'Format', oldFormat);
end
