www.pudn.com > gps-matlab.rar > PRADR.M, change:2001-01-20,size:6080b


%                                   pradr.m 
%  Scope:   This MATLAB macro computes pseudorange and accumulated delta range for a 
%           specified satellite. WGS-84 constants are used. 
%  Usage:   [pr,adr] = pradr(upos,uposlla,uelaz,svpos,tsim,step,svid,flags) 
%  Description of parameters: 
%           upos    - input, user position in ECEF, the components are in meters 
%           uposlla - input, user position in geodetic coordinates (latitude/longitude/ 
%                     altitude above ellipsoid), the components are in radians, radians, 
%                     and meters (optional, it is needed when iono correction flag is set) 
%           uelaz   - input, elevation and azimuth angles as follows 
%                     uelaz(1) - elevation angle, in radians 
%                     uelaz(2) - azimuth angle, in radians 
%           svpos   - input, ECEF satellite position, the components in meters 
%           tsim    - input, simulation time (time of week), in seconds 
%           step    - input, step number; the value is used when when one of the following  
%                     are applied: SA, multipath, user clock, pseudorange noise, 
%                     ambiguity, delta range noise 
%           svid    - input, satellite id 
%           flags   - input, flags with the following meaning  
%                     flags(1)  =  0  iono error is not used 
%                              !=  0  iono error is used; the coefficients alpha and beta 
%                                     should be initialized before calling this module 
%                     flags(2)  =  0  tropo error is not used 
%                              !=  0  tropo error is used; geoid heights data file (e.g.  
%                                     tgeoid84.dat) should be loaded before calling this  
%                                     module 
%                     flags(3)  =  0  SA error is not used 
%                              !=  0  SA error is used; SA data file (e.g.  safile.mat) 
%                                     should be loaded before calling this module 
%                     flags(4)  =  0  multipath is not used 
%                              !=  0  multipath is used; multipath data file (e.g. mpfile. 
%                                     mat) should be loaded before calling this module 
%                     flags(5)  =  0  user clock bias is not used 
%                              !=  0  user clock bias is used; user clock bias data file 
%                                     (e.g. ucbfile.mat) should be loaded before calling  
%                                     this module  
%                     flags(6)  =  0  earth rotation error is not used 
%                              !=  0  earth rotation error is used 
%                     flags(7)  =  0  pseudorange noise is not used 
%                              !=  0  pseudorange noise is used; prnoise(nrstep,svid)  
%                                     should be generated in the main program  
%                     flags(8)  =  0  carrier phase is not generated 
%                              !=  0  carrier phase is generated; ambiguity data file  
%                                     (e.g. ambfile.mat) file should be loaded before  
%                                     calling this module  
%                     flags(9)  =  0  delta range noise is not used 
%                              !=  0  delta range noise is used;  adrnoise(nrstep,svid)  
%                                     should be generated in the main program                                 
%            pr     - output, pseudorange, in meters 
%            adr    - output, accumulated delta range, in meters (optional) 
%            Note that some data are transmitted by using global variables, namely alpha  
%            and beta coefficients for iono correction, geoid height data, SA data,  
%            multipath data, user clock bias data, ambiguity constants, pseudorange noise, 
%            accumulated delta range noise, and lambda. 
%  Remark:  It is assumed that the satellite is visible. 
%  External Matlab macros used:  ionoc, tropoc1, uercor, wgs84con 
%  Last update:  01/20/01 
%  Copyright (C) 1999-01 by LL Consulting. All Rights Reserved. 
 
function    [pr,adr] = pradr(upos,uposlla,uelaz,svpos,tsim,step,svid,flags) 
 
wgs84con; 
% global constants used:  rot_rate, c_speed 
 
global  alpha  beta  tgeoid  sa  mpath  ucbias  ambig   prnoise  adrnoise lambda 
 
mpfactor = 0.005*lambda;      %  multipath scaling factor used in adr determination 
 
%  Determine iono error 
 
if  flags(1) ~= 0 
   ionoerr = ionoc(uposlla(1),uposlla(2),uelaz(1),uelaz(2),tsim,alpha,beta); 
else 
   ionoerr = 0.; 
end 
 
%  Determine tropo error 
 
if  flags(2) ~= 0 
   tropoerr = tropoc1(uposlla(1),uposlla(2),uposlla(3),uelaz(1),tgeoid); 
else 
   tropoerr = 0.; 
end 
 
%  Determine SA error 
 
if  flags(3) ~= 0 
   saerr = sa(step,svid); 
else 
   saerr = 0.; 
end 
 
%  Determine multipath error 
 
if  flags(4) ~= 0 
   mperr = mpath(step,svid); 
else 
   mperr = 0.; 
end 
 
%  Determine user clock bias  
 
if  flags(5) ~= 0 
   ucberr = ucbias(step,1);    %  data for the first receiver 
else 
   ucberr = 0.; 
end 
 
%  Determine earth rotation correction 
 
if  flags(6) ~= 0 
   grange = norm(upos - svpos); 
   dt = grange / c_speed; 
   ererr = uercor(upos,dt); 
else 
   ererr = 0.; 
end 
 
%  Determine pseudorange noise 
 
if  flags(7) ~= 0 
   prnerr = prnoise(step,svid); 
else 
   prnerr = 0.; 
end 
 
%  Determine the adjusted geometric range 
 
grange = norm(upos + ererr - svpos); 
pr = grange;       
 
%  Computation of pseudorange 
 
pr = grange + ionoerr + tropoerr + saerr + mperr + ucberr + prnerr; 
 
%  Computation of accumulated delta range 
 
if  flags(8) ~= 0 
    
   adr =  grange - ionoerr + tropoerr + saerr + mpfactor*mperr + ucberr - lambda*ambig(svid); 
%   adr =  grange - ionoerr + tropoerr + saerr + mpfactor*mperr + ucberr - ambig(svid); 
   if flags(9) ~= 0 
       adr = adr + adrnoise(step,svid); 
   end    
 
end