function  matchbox(axes_to_change, axes_to_use, varargin);
% matchbox(axes_to_change, axes_to_use, varargin)
% axes_to_change:  handle for the current axes object
% axes_to_use: handle for another axes object whose diemnsions we will clone
% 
% use the following from axes_to_use and set them in axes_to_change
% 
% 'width'
% 'height'
% 'bottom'
% 'top'
% 'all'
%
% eg: matchbox(ax_to_change, ax_to_use, 'width', 'height')


%[left, bottom, width, height]

posmask = zeros(1,4);

for ii=1:length(varargin)
   if (strcmp(varargin{ii}, 'left')),              posmask(1) = 1;
   elseif (strcmp(varargin{ii}, 'bottom')),        posmask(2) = 1;
   elseif (strcmp(varargin{ii}, 'width')),         posmask(3) = 1;
   elseif (strcmp(varargin{ii}, 'height')),        posmask(4) = 1;
   elseif (strcmp(varargin{ii}, 'all')),           posmask = ones(1,4);
   else, help matchbox, error('something didn''t match in paramter list'), end
end
      

cur_pos = get(axes_to_change,'pos');
use_pos = get(axes_to_use,'pos');
new_pos = cur_pos;
new_pos(find(posmask)) = use_pos(logical(posmask));
set(axes_to_change, 'pos', new_pos);