Iteratively loop for computing (WHILE)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sebastian Ciuban
am 9 Jul. 2014
Kommentiert: Sebastian Ciuban
am 9 Jul. 2014
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)];
0 Kommentare
Akzeptierte Antwort
Geoff Hayes
am 9 Jul. 2014
Since Xo, Yo, Zo, and To represent the approximate position and the code refines/corrects the position to Xa, Ya, Za, and Ta then it seems that you should put the while loop in the code where you first use Xo, Yo, Zo, and To i.e. at the calculation of the geometric distance ,replacing the o variables with the a ones.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!