how can i run iterations?

3 ビュー (過去 30 日間)
Postit123
Postit123 2020 年 10 月 3 日
編集済み: KALYAN ACHARJYA 2020 年 10 月 3 日
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;

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 10 月 3 日
編集済み: KALYAN ACHARJYA 2020 年 10 月 3 日
......
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.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by