Iteratively loop for computing (WHILE)
Show older comments
I have this function and I have to make it compute my data iteratively. The new values obtained at final (Xa, Ya, Za, Ta) must be used as new values for iteration until (X(1)(dx),X(2)(dy), X(3)(dz)) < eps..I have trouble in putting the "while" command in the right place. I know this is very simple, and I may be a moron for not being able to figure this myself..but at this point I can't find the right solution..I would appreciate if anyone would help me with a hint.
function [P,DP] = compute_position(poz_apr,CoordSV,PR)
%Speed of light m/s
c = 0.299792458e9;
%Aproximate position
Xo=poz_apr(1);
Yo=poz_apr(2);
Zo=poz_apr(3);
To=poz_apr(4);
%Satellite coordinates
SVx=CoordSV(1,:)';
SVy=CoordSV(2,:)';
SVz=CoordSV(3,:)';
SVt=CoordSV(4,:)';
%Corrected pseudodistance
PR=PR+(SVt.*c);
%Geometric distance
p=sqrt((SVx-Xo).^2+(SVy-Yo).^2+(SVz-Zo).^2);
% Free terms vector
L=PR-p;
%Partial derivatives
DX= -(SVx-Xo)./p;
DY= -(SVy-Yo)./p;
DZ= -(SVz-Zo)./p;
DT = ones(length(PR),1).*(-c*1e-9);
%Coeff matrix
A=[DX DY DZ DT];
%Unknown terms (dx dy dz dt) matrix
X = inv(A'*A) * A' * L;
%Corrected position
Xa=Xo + X(1); % dx= X(1)
Ya=Yo + X(2); % dy= X(2)
Za=Zo + X(3); % dz= X(3)
Ta=To + X(4); % dt= X(4)
P=[Xa Ya Za Ta];
DP=[X(1); X(2); X(3); X(4)];
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!