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

📄 xsaerr.m

📁 GPS TOOLBOX包含以下内容: 1、GPS相关常量和转换因子; 2、角度变换; 3、坐标系转换: &#61656 点变换; &#61656 矩阵变换; &#61656 向量变换
💻 M
字号:
%                                    xsaerr.m
%  Scope:   This MATLAB program generates and saves the SA (Selective Availability) 
%           errors for a specified number of satellites and time steps.
%  Usage:   xsaerr
%  Inputs:  - from keyboard the user should enter the following data: 
%             - maximum number of satellites used, nrsv (default is 12)
%             - number of time steps to be generated, nrsteps (default is 1800)
%             - random number seed value (default is 0)
%             - SA model data (second order Gauss-Markov process); default data is 
%               available
%           - selection of the storage data file
%             - safile.mat 
%             - selected name for ASCII data file
%             - none, no storage (default)
%           - selection of multipath plots from generated data
%             - satellite(s) number for which the generated data is plotted
%           - application specific parameters are initialized by default (see
%             sigma, order and wn) and time step is 1 second
%  Outputs: - output file storing the SA errors, mat-file safile.mat or defined 
%             ASCII data file; the output array has nrsteps rows and nrsv columns,
%             each row contains multipath data for a specific SA model and all 
%             selected satellites
%           - plot of SA errors versus time step, for the specified satellites 
%  External Matlab macros used:  gmp2, rms
%  Reference: [1] Anonym., Minimum operational standards for airborne supplemental
%                 navigation equipment using Global Positioning System (GPS). 
%                 Document No. RTCA/DO-208, July 1991, prepared by SC-159
%  Last update:  01/17/01
%  Copyright (C) 1996-01 by LL Consulting. All Rights Reserved.

clear
close all
yes = 'y';

disp('  ');
nrsv = input('Enter maximum number of satellites used, nrsv (default is 12) -- >  ');
if isempty(nrsv)
   nrsv = 12;
end   
disp('  ');
nrsteps = input('Enter number of steps to be generated, nrsteps (default is 1800) -- >  ');
if isempty(nrsteps)
   nrsteps = 1800;
end   
disp('  ');
sa = zeros(nrsteps,nrsv);

%  Initialization  (depending on specific application)

answer1 = input('Do you want to use the default data for SA model? (y/n)[y] ','s');
if  isempty(answer1)
   answer1 = yes;
end
if (strcmp(answer1,yes) == 1)
   w0 = 0.012;                %  natural frequency in radians/second
   beta = 0.707106781;        %  value of  1/sqrt(2.0) , damping factor
   csq = 0.002585;            %  constant  c**2  in meters**2          
   deltat = 1.0;              %  time step in seconds
else
   w0 = input('Specify the natural frequency in radians/second -->  ');
   beta = input('Specify the damping factor (less than 1.) -->  ');
   csq = input('Specify the constant c**2 in meters**2 -->  ');
   deltat = input('Specify the time step in seconds -->  ');
end

disp('  ');
disp('Select the initial seed value, the default is 0');
answer2 = input('Do you want to use the default value? (y/n)[y] ','s');
if  isempty(answer2)
   answer2 = yes;
end
if (strcmp(answer2,yes) == 1)
   iseed = 0;
else
   iseed = input('Specify the value --> ');
end  
rand('seed',iseed);
disp('  ');

%  Determine SA error data

for kk = 1:nrsv
      
  [xp,xv] = gmp2(nrsteps,w0,beta,csq,deltat);
  sa(:,kk) = xp;
   
end

%  Store the multipath generated data into mpfile.mat or selected ASCII data file

disp('Specify where you want to save the generated data ');
disp('     Enter  1   for the file safile.mat');
disp('     Enter  2   for the ASCII data file to be selected');
disp('     Enter  3   for NOT saving');
answer2 = input('Enter your selection  (default is 3) -- >  ');
if isempty(answer2)
   answer2 = 3;
end   
if  (answer2 == 1)
   save   safile  sa
elseif  (answer2 == 2)
   f2 = input('Enter the SA error ASCII data file (with extension) -- > ','s');
   for k = 1:nrstep
      for  kk = 1:nrsv
         fprintf(f2,'%14.7e  ',sa(k,kk));
      end
      fprintf(f2,'\n'); 
   end
else
    fprintf('\nThe generated data is NOT saved\n');
end
 
 %  Execute plots of generated multipath data
 
disp('  ');
answer3 = input('Execute plots of generated SA error data? (y/n)[y] ','s');
disp('  ');
if isempty(answer3)
   answer3 = yes;
end   
k = 1;
x = 1:nrsteps;
while (strcmp(answer3,yes))
   sat_sel = input('Select the sateliite number (1 to nrsv) -->  ');
   if ((sat_sel < 1) | (sat_sel > nrsv))
      fprintf('Selection is not in range\n\n');
      disp('  ');
      return
   end   
   disp('  ');
   y = sa(:,sat_sel);
   xmean = mean(y);
   xstd = std(y);
   xrms = rms(y);
   temp1 = ['mean = ',num2str(xmean)];
   temp2 = ['st.dev. = ',num2str(xstd)];
   temp3 = ['rms = ',num2str(xrms)];
   g = [temp1,' ;   ',temp2,' ;   ',temp3];
   disp('Execute SA error graph - ');
   disp('Select the mouse position to insert statistics.');
   disp('Press a key to continue...');
   pause
   figure(k)
   plot(x,y), grid
   xlabel(['Time step number (time step = ' num2str(deltat) ' second(s))']);
   ylabel('SA error, in meters');
   aa = 'SA error  versus  Time step, for satellite number ';
   title([aa num2str(sat_sel)]); 
   gtext(g);                   %  mouse placement of the text on a graph
   disp('  ');
   answer3 = input('Do you want to execute another plot? (y/n)[n] --> ','s');
   if isempty(answer3)
      answer3 = 'n';
   end
   k = k + 1;
   disp('  ');
end

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

⌨️ 快捷键说明

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