⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xatransf.m

📁 GPS TOOLBOX包含以下内容: 1、GPS相关常量和转换因子; 2、角度变换; 3、坐标系转换: &#61656 点变换; &#61656 矩阵变换; &#61656 向量变换
💻 M
字号:
%                             xatransf.m
%  Scope:   This MATLAB program performs the following unit transformations
%           of a specified angle(s):
%           1) from degrees/minutes/seconds to radians transformation
%           2) from radians to degrees/minutes/seconds transformation
%  Usage:   xatransf
%  Inputs:  - name of the output file if selected (the default is the screen)
%           1) For the degrees/minutes/seconds to radians:
%              - degrees value of the angle (including sign)
%              - minutes value of the angle
%              - seconds value of the angle
%              The values can be entered from keyboard or from a specified 
%              file (in this case each row/record contains the degrees/
%              minutes/seconds value of an angle).
%           2) For the radians to degrees/minutes/seconds:
%              - radians value of the angle (including sign)
%              The values can be entered from keyboard or from a specified 
%              file (in this case each row/record contains the radians value
%              of an angle).
%  Outputs: - input/output data stored on the selected output file or
%             displayed on the computer screen, namely
%             - values of the input/output angle in radians
%             - values of the output/input angle in degrees/minutes/seconds
%  External Matlab macros used:  tadmsrad, taraddms
%  Last update:  08/28/00
%  Copyright (C) 1996-00 by LL Consulting. All Rights Reserved.

clear  

yes = 'y';
answer = yes;

disp('  ');
answer1 = input('Do you want to save the results? (y/n)[n] --> ','s');
if isempty(answer1)
   answer1 = 'n';
end   
disp('  ');
if (strcmp(answer1,yes) == 1)
   f2 = input('Specify the output filename (with extension) -->  ','s');
   disp('  ');
else
   f2 = 1;      %  output to the screen
end

disp('   Select :  1  --> degrees/minutes/seconds to radians transformation');
disp('             2  --> radians to degrees/minutes/seconds transformation');
disp('  ');
select = input('Make the selection -->  ');
disp('  ');

if (select == 1)                       % degrees/minutes/seconds to radians 

   while (strcmp(answer,yes) == 1)     

      answer2 = input('Enter data from keyboard? (y/n)[y] --> ','s');
      if isempty(answer2)
         answer2 = yes;
      end   
      disp('  ');

      if (strcmp(answer2,yes) == 1)
         adeg = input('Enter degrees value of the angle (including sign) --> ');   
         amin = input('Enter minutes value of the angle (positive number) --> ');   
         asec = input('Enter seconds value of the angle (positive number) --> '); 
         disp('  ');
         nrow = 1;
      else   
         clear  tt
         f1 = input('Specify input filename (with extension) --> ','s');
         disp('  ');

%     Read the input data file

         tt = load(f1);
         [nrow,ncol] = size(tt);

         if  ncol ~= 3
            disp('Error - XATRANSF; check the input data file');
            disp('  ');
            disp('End of the program  XATRANSF');
            disp('  ');           
         end
   
         adeg = tt(:,1);
         amin = tt(:,2);
         asec = tt(:,3);

      end

%  Compute the value of the angle(s) in radians

      for k = 1:nrow
         temp = tadmsrad(adeg(k),amin(k),asec(k));
         arad(k) = temp;
      end

%  Save the results if the output file is specified or display on screen

      fprintf(f2,'\n**************************************************');
      fprintf(f2,'******************************\n');
      fprintf(f2,'\n*****   Value of the angle(s)   *****\n');
      fprintf(f2,'      degrees   minutes   seconds  \n');
      for k = 1:nrow
         fprintf(f2,' %10.0f  %8.0f  %10.5f\n',adeg(k),amin(k),asec(k));
      end
      fprintf(f2,'\n*****   Value of the angle(s) in radians  *****\n');
      for k = 1:nrow
         fprintf(f2,'%30.12f \n',arad(k));
      end
      fprintf(f2,'\n**************************************************');
      fprintf(f2,'******************************\n');

%  Select another computation, if desired

      disp('  ');
      answer = input('Do you want another computation? (y/n)[n] --> ','s');
      if isempty(answer)
         answer = 'n';
      end   
      disp('  ');

   end

elseif (select == 2)                   % radians to degrees/minutes/seconds 

   while (strcmp(answer,yes) == 1)

      answer2 = input('Enter data from keyboard? (y/n)[y] --> ','s');
      if isempty(answer2)
         answer2 = yes;
      end   
      disp('  ');

      if (strcmp(answer2,yes) == 1)
         arad(1) = input('Enter value of the angle in radians --> ');
         nrow = 1;
         disp('  ');
      else   
         clear  tt
         f1 = input('Specify input filename (with extension) --> ','s');
         disp('  ');

%     Read the input data file

         tt = load(f1);
         [nrow,ncol] = size(tt);

         if  ncol ~= 1
            disp('Error - XATRANSF; check the input data file');
            disp('  ');
            disp('End of the program  XATRANSF');
            disp('  ');
         end
   
         arad = tt;

      end

%  Compute the value of the angle(s) in degrees/minutes/seconds

      for k = 1:nrow
         [temp1,temp2,temp3] = taraddms(arad(k));
         adeg(k) = temp1;
         amin(k) = temp2;
         asec(k) = temp3;
      end

%  Save the results if the output file is specified or display on screen

      fprintf(f2,'\n**************************************************');
      fprintf(f2,'******************************\n');
      fprintf(f2,'\n*****   Value of the angle(s) in radians  *****\n');
      for k = 1:nrow
         fprintf(f2,'%30.7f \n',arad(k));
      end
      fprintf(f2,'\n*****   Value of the angle(s)   *****\n');
      fprintf(f2,'      degrees   minutes   seconds  \n');
      for k = 1:nrow
         fprintf(f2,' %10.0f  %8.0f  %10.3f\n',adeg(k),amin(k),asec(k));
      end
      fprintf(f2,'\n**************************************************');
      fprintf(f2,'******************************\n');

%  Select another computation, if desired

      disp('  ');
      answer = input('Do you want another computation? (y/n)[n] --> ','s');
         if isempty(answer)
      answer = 'n';
      end   
      disp('  ');

   end

else

      disp('Selection is not in the designated range');
      disp('  ');

end

disp('End of the program  XATRANSF');
disp('  ');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -