0001 function scaleruler(structure)
0002
0003
0004
0005
0006
0007
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
0013 x0=structure(1);
0014 y0=structure(2);
0015 lengthscale=structure(3);
0016 widthscale=structure(4);
0017 numberofticks=structure(5);
0018
0019
0020 unitlength=lengthscale/(numberofticks -1);
0021 flag=-1;
0022
0023 Bd=[x0 y0];
0024 Bu=[x0 y0+widthscale];
0025 Tick=0;
0026
0027
0028 xt=Bu(1);
0029 yt=Bu(2)+widthscale;
0030 text(xt,yt,num2str(Tick),'FontSize',13,'FontWeight','b');
0031
0032
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
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
0048 flag=-flag;
0049
0050
0051 xt=Bu(1);
0052 yt=Bu(2)+widthscale;
0053 text(xt,yt,num2str(Tick/1000),'FontSize',13,'FontWeight','b');
0054 end
0055
0056
0057 xt=Bu(1)+unitlength;
0058 yt=Bu(2);
0059 text(xt,yt,'km','FontSize',16,'FontWeight','b');