Home > mapstuff > degmins.m

degmins

PURPOSE ^

DEGMINS Creates a degrees and minutes label for use in MAPAX routine.

SYNOPSIS ^

function degstring=degmins(degrees,ndigit);

DESCRIPTION ^

 DEGMINS Creates a degrees and minutes label for use in MAPAX routine.

 Usage:  degstring=degmins(degrees,ndigit);

    Inputs:  degrees = decimal degrees
             ndigit  = number of decimal places for minutes

    Outputs: degstring = string containing label
 Version 1.0 Rocky Geyer (rgeyer@whoi.edu)
 Version 1.1 J.List (jlist@usgs.gov)
             fixed bug

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function degstring=degmins(degrees,ndigit);
0002 % DEGMINS Creates a degrees and minutes label for use in MAPAX routine.
0003 %
0004 % Usage:  degstring=degmins(degrees,ndigit);
0005 %
0006 %    Inputs:  degrees = decimal degrees
0007 %             ndigit  = number of decimal places for minutes
0008 %
0009 %    Outputs: degstring = string containing label
0010 % Version 1.0 Rocky Geyer (rgeyer@whoi.edu)
0011 % Version 1.1 J.List (jlist@usgs.gov)
0012 %             fixed bug
0013 degrees=degrees(:);
0014 
0015 for i=1:length(degrees);
0016 
0017 if degrees(i)<0
0018   degrees(i)=-degrees(i);
0019 end
0020 
0021 deg(i,1)=floor(degrees(i));
0022 deg(i,2)=(degrees(i)-deg(i,1))*60;
0023 
0024 if ndigit==0;
0025   degstring(i,:)=sprintf('%3d%s%2.2d%s',deg(i,1),...
0026                  setstr(176),round(deg(i,2)),'''');
0027 elseif ndigit==1;
0028   deg(i,3)=round(10*abs(round(deg(i,2))-deg(i,2)));
0029   degstring(i,:)=sprintf('%3d%s%2.2d%s%1.1d%s',deg(i,1),...
0030                  setstr(176),round(deg(i,2)),'.',deg(i,3),'''');
0031 elseif ndigit==2;
0032   deg(i,3)=round(100*abs(round(deg(i,2))-deg(i,2)));
0033   degstring(i,:)=sprintf('%3d%s%2.2d%s%2.2d%s',deg(i,1),...
0034                  setstr(176),round(deg(i,2)),'.',deg(i,3),'''');
0035 end;
0036 
0037 end

Generated on Wed 30-Nov-2005 15:38:18 by m2html © 2003