scaleruler

PURPOSE ^

SCALERULER - overlay a scale ruler on current plot

SYNOPSIS ^

function scaleruler(structure)

DESCRIPTION ^

SCALERULER - overlay a scale ruler on current plot

   Usage:
      scaleruler(structure)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function scaleruler(structure)
0002 %SCALERULER - overlay a scale ruler on current plot
0003 %
0004 %   Usage:
0005 %      scaleruler(structure)
0006 
0007 %Go through structure and fill missing arguments
0008 if length(structure)~=5
0009     error('plotmodel error message: bad number of input arguments for scaleruler: [x0 y0 length thickness numberofticks]');
0010 end
0011 
0012 %retrieve north arrow parameters
0013 x0=structure(1);
0014 y0=structure(2);
0015 lengthscale=structure(3);
0016 widthscale=structure(4);
0017 numberofticks=structure(5);
0018 
0019 %initialize some coordinates
0020 unitlength=lengthscale/(numberofticks -1);
0021 flag=-1;
0022 
0023 Bd=[x0 y0];
0024 Bu=[x0 y0+widthscale];
0025 Tick=0;
0026 
0027 %Text
0028 xt=Bu(1);
0029 yt=Bu(2)+widthscale;
0030 text(xt,yt,num2str(Tick),'FontSize',13,'FontWeight','b');
0031 
0032 %loope over the patches
0033 for i=1:numberofticks-1,
0034     Au=Bu;
0035     Ad=Bd;
0036     Bu=[Au(1)+unitlength Ad(2)+widthscale];
0037     Bd=[Ad(1)+unitlength Ad(2)];
0038     Tick=Tick+unitlength;
0039 
0040     %pathes
0041     if flag==-1
0042         p=patch([Ad(1) Bd(1) Bu(1) Au(1)],[Ad(2) Bd(2) Bu(2) Au(2)],'Black');
0043     else
0044         p=patch([Ad(1) Bd(1) Bu(1) Au(1)],[Ad(2) Bd(2) Bu(2) Au(2)],'White');
0045     end
0046 
0047     %flip flag
0048     flag=-flag;
0049 
0050     %Text
0051     xt=Bu(1);
0052     yt=Bu(2)+widthscale;
0053     text(xt,yt,num2str(Tick/1000),'FontSize',13,'FontWeight','b');
0054 end
0055 
0056 %Text
0057 xt=Bu(1)+unitlength;
0058 yt=Bu(2);
0059 text(xt,yt,'km','FontSize',16,'FontWeight','b');

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003