📄 xuposdg.m
字号:
% xuposdg.m
% Scope: This MATLAB program computes GPS user's position by using a direct
% (non-iterative) GPS solution method proposed by Bancroft [1], [2],
% when at least four ECEF satellite positions and the corresponding
% pseudoranges are known.
% Usage: xuposdg
% Inputs: - name of the output file if selected, otherwise the data are
% displayed on screen
% - name of the ASCII input file with at least four rows and four
% columns; each row contains the three components of the ECEF
% satellite position and the corresponding pseudorange (all
% values are in meters)
% Outputs: - input data, ECEF position and corresponding pseudorange for
% each satellite
% - computed user's ECEF position and computed user's clock bias
% measurement in units of distance (for each solution)
% External Matlab macros used: uposdg
% References:
% [1] Bancroft, S., An algebraic solution of the GPS equations.
% IEEE Transactions on Aerospace and Electronic Systems, vol.
% AES-21, No. 7, 1985, pp. 56-59.
% [2] Chaffee, J. W., Abel, J. S., Bifurcation of pseudorange
% equations. Institute of Navigation, Proceedings of the 1993
% National Technical Meeting, San Francisco, CA, Jan. 20-22,
% 1993, pp. 203-211.
% Last update: 08/24/00
% Copyright (C) 1996-00 by LL Consulting. All Rights Reserved.
clear
yes = 'y';
disp(' ');
% Specify the output file if selected
answer1 = input('Do you want to save the results? (y/n)[n] --> ','s');
disp(' ');
if isempty(answer1)
answer1 = 'no';
end
if (strcmp(answer1,yes) == 1)
f2 = input('Specify the output filename (with extension) --> ','s');
disp(' ');
else
f2 = 1; % output to the screen
end
answer2 = yes;
while (strcmp(answer2,yes) == 1)
clear tt
disp('Enter satellite+pseudorange input data - the default is sv7posr.dat');
answer3 = input('Do you want to use the default data file? (y/n)[y] ','s');
if isempty(answer3)
answer3 = yes;
end
if (strcmp(answer3,yes) == 1)
f1 = 'sv7posr.dat';
else
disp(' ');
f1 = input('Specify the input filename (with extension) --> ','s');
end
disp(' ');
% Read the input data file
tt = load(f1);
[nrow,ncol] = size(tt);
if (nrow < 4) | (ncol ~= 4)
disp('Error1 - XUPOSDG; check the input data - row/column number');
disp('The input file should have at least 4 rows and 4 columns');
disp(' ');
disp('End of the program XUPOSDG ');
disp(' ');
return
end
svpos = tt(1:nrow,1:3);
rho = tt(1:nrow,4);
% Write input data
fprintf(f2,'******************************** INPUT DATA ************');
fprintf(f2,'********************\n\n');
for k = 1:nrow
fprintf(f2,'For SV # %3.0f \n',k);
fprintf(f2,' ***** ECEF position (in meters) :\n');
fprintf(f2,'%20.7f %20.7f %20.7f\n',svpos(k,1),svpos(k,2),svpos(k,3));
fprintf(f2,' ***** Pseudorange (in meters) :\n');
fprintf(f2,'%20.7f\n\n',rho(k));
end
% Compute ECEF user's position
[nsol,upos,ucbias] = uposdg(svpos,rho);
% Save computed results into an external file
fprintf(f2,'******************************* RESULTS *****************');
fprintf(f2,'********************\n\n');
if nsol == 0
fprintf(f2,'There are no GPS solutions \n\n');
elseif nsol == 1
fprintf(f2,'Computed user"s ECEF position (in meters) :\n');
fprintf(f2,'%20.7f %20.7f %20.7f \n\n',upos(1),upos(2),upos(3));
fprintf(f2,'Computed user"s clock bias measured in units of distance ');
fprintf(f2,' (in meters) :\n %24.14f \n\n',ucbias);
elseif nsol == 2
fprintf(f2,'**** First GPS solution \n');
fprintf(f2,'Computed user"s ECEF position (in meters) :\n');
fprintf(f2,'%20.7f %20.7f %20.7f \n\n',upos(1),upos(2),upos(3));
fprintf(f2,'Computed user"s clock bias measured in units of distance ');
fprintf(f2,' (in meters) :\n %24.14f \n\n',ucbias);
fprintf(f2,'**** Second GPS solution \n');
fprintf(f2,'Computed user"s ECEF position (in meters) :\n');
fprintf(f2,'%20.7f %20.7f %20.7f \n\n',upos(1),upos(2),upos(3));
fprintf(f2,'Computed user"s clock bias measured in units of distance ');
fprintf(f2,'(in meters) :\n %24.14f \n\n',ucbias);
else
disp('Error2 - XUPOSDG; check the output data "nsol" from uposdg');
disp(' ');
disp('End of the program XUPOSDG ');
disp(' ');
return
end
fprintf(f2,'***********************************************************');
fprintf(f2,'********************\n\n');
% Select another computation, if desired
answer2 = input('Do you want another computation? (y/n)[n] --> ','s');
if isempty(answer2)
answer2 = 'n';
end
disp(' ');
end
disp('End of the program XUPOSDG ');
disp(' ');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -