function paper(left, bottom, width, height, Marg)
% function paper(left, bottom, width, height, Marg)
% 11 Apr 2005
% David S. Ciochetto
%
% A function to set up default paper sizes for printing plots
% and for setting the size that the figure window will be
% and the location of the figure window.
%
% left, bottom, width and height are for the figure windows.
% left and bottom indicate the location of the figure window (pixels) relative to the
% bottom left hand corner of the screen. Default values are to shift the window
% up 50 pixels and right 0 pixels. The figures are set to occupy a certain % of the
% screen relative to the specified corner based on the values in width and height.
%
% Figures will be set up to occupy the full sheet of an 8.5" x 11" piece of paper.
% Margin indicates the margin to set for all boundaries in inches. The default
% value is 0.25".
%
% NOTES:
%		20050411 Changed the variable Margin as Matlab has a m-file with the same
%   name and exist think that it is there.
%
% USES:
%


% Get the size of the display for the particular machine.
% scrsz = [left bottom width height] in pixels
scrsz=get(0,'ScreenSize');
% Default location of the bottom left hand corner of figure windows in pixels
up = 50; rght = 0;
% Default horizontal and vertical size of figure windows as % of screen
phor = 1.00; pvert = 0.80;
mgn = 0.25;		% Default paper margin of 1/4"
pwid = 8.5;		% Default Paper width in inches
phgh = 11;		% Default Paper height in inches

if ~exist('Marg')
	Marg=mgn;
end

if ~exist('left')
	left=rght;
end

if ~exist('bottom')
	bottom=up;
end

if ~exist('width')
	width=phor;
end

if ~exist('height')
	height=pvert;
end

papsiz = [Marg,Marg,pwid-Marg*2,phgh-Marg*2];
figpos = [scrsz(1)+left scrsz(2)+bottom width*scrsz(3) height*scrsz(4)];
set(0,'DefaultFigurePosition',figpos,'DefaultFigurePaperPosition',papsiz)
