how can i run iterations?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi
I'd like to replace "ep" matrix with "new" matrix for next iteration until the difference between new and ep gets lower than 0.01.
I think all I need is a simple equation that can relate "ep" and "new", but I have no idea how to do that.
function [H,y,true] = guess_new(sat,psr,ep,er,c)
% sat [nX4] * n = the number of satellites
% ep [1X3] : estimated position
% c : light of speed
% psr : pseudorange [nX1]
% er : user clock error
%%
n = size(sat,1);
new = ones(4,1);
while abs(new(1:3)- ep) > 0.01
for i = 1 : n
x(i) = (ep(1) - sat(i,1));
y(i) = (ep(2) - sat(i,2));
z(i) = (ep(3) - sat(i,3));
rho(i) = sqrt(x(i)^2+y(i)^2+z(i)^2);
G(i) = rho(i) + c*er;
end
% Partial Matrix H
H = [x(:) y(:) z(:) c*ones(n,1)]./rho(:);
% Measurement residual vector y
y = [psr(:) - G(:)];
% delta x,y,z,time error
del = inv(H.'*H)*H.'*y;
% update the initial guess
new = [ep'; er] + del;
end
true = new;
0 Kommentare
Antworten (1)
KALYAN ACHARJYA
am 3 Okt. 2020
Bearbeitet: KALYAN ACHARJYA
am 3 Okt. 2020
......
while abs(new(1:3)- ep)>0.01
for i = 1 : n
x(i) = (ep(1) - sat(i,1));
y(i) = (ep(2) - sat(i,2));
z(i) = (ep(3) - sat(i,3));
rho(i) = sqrt(x(i)^2+y(i)^2+z(i)^2);
G(i) = rho(i) + c*er;
end
ep=new; % Replace ep with new
end
......
Note: Please note on generation of new "new" after execution of for loop.
0 Kommentare
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!