Home > analyzePRF > utilities > drawrectangle.m

drawrectangle

PURPOSE ^

function h = drawrectangle(x,y,sz1,sz2,linestyle)

SYNOPSIS ^

function h = drawrectangle(x,y,szx,szy,linestyle)

DESCRIPTION ^

 function h = drawrectangle(x,y,sz1,sz2,linestyle)

 <x> is x-position of rectangle center
 <y> is y-position of rectangle center
 <szx> is size along the x-direction
 <szy> is size along the y-direction.  if [], default to <szx>.
 <linestyle> (optional) is like 'r-'.  default: 'r-'.

 draw a rectangle on the current figure.
 return the handle to the line object that we create.

 example:
 figure; drawrectangle(5,2,4,[],'r-'); axis equal;

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function h = drawrectangle(x,y,szx,szy,linestyle)
0002 
0003 % function h = drawrectangle(x,y,sz1,sz2,linestyle)
0004 %
0005 % <x> is x-position of rectangle center
0006 % <y> is y-position of rectangle center
0007 % <szx> is size along the x-direction
0008 % <szy> is size along the y-direction.  if [], default to <szx>.
0009 % <linestyle> (optional) is like 'r-'.  default: 'r-'.
0010 %
0011 % draw a rectangle on the current figure.
0012 % return the handle to the line object that we create.
0013 %
0014 % example:
0015 % figure; drawrectangle(5,2,4,[],'r-'); axis equal;
0016 
0017 % input
0018 if ~exist('linestyle','var') || isempty(linestyle)
0019   linestyle = 'r-';
0020 end
0021 if isempty(szy)
0022   szy = szx;
0023 end
0024 
0025 % prep figure
0026 hold on;
0027 
0028 % do it
0029 h = plot([x-szx/2 x+szx/2 x+szx/2 x-szx/2 x-szx/2], ...
0030          [y+szy/2 y+szy/2 y-szy/2 y-szy/2 y+szy/2],linestyle);

Generated on Wed 18-Jun-2014 21:47:41 by m2html © 2005