필터 지우기
필터 지우기

how can i run iterations?

조회 수: 2 (최근 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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by