- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
function Result = GPS(Guess)
% Givens
p = 26570;
c = 299792.458;
%x = 0;
%y = 0;
%z = 6370;
%d = 0.0001;
%Creates A_i, B_i, C_i, t_i
for i=0:3
m = (pi/2)*(1/3)*i;
n = (2*pi)*(1/3)*i;
A(i+1) = p*cos(m)*cos(n);
B(i+1) = p*cos(m)*sin(n);
C(i+1) = p*sin(m);
R = sqrt((A(i+1)-Guess(1))^2+(B(i+1)-Guess(2))^2+(C(i+1)-Guess(3))^2);
t(i+1) = Guess(4) + R/c;
% Maximum position error: -1, -1, -1, 1
end
max = 0;
dt = t;
maxOne = t;
maxf = 0;
for k = 1:500
one = 10^-8 * randi([-1,1],1,4);
dt = t + one;
% Multi-variable Newton's Method
F=@(IN) [(IN(1)-A(1))^2+(IN(2)-B(1))^2+(IN(3)-C(1))^2-(c*(dt(1)-IN(4)))^2 ;...
(IN(1)-A(2))^2+(IN(2)-B(2))^2+(IN(3)-C(2))^2-(c*(dt(2)-IN(4)))^2 ;...
(IN(1)-A(3))^2+(IN(2)-B(3))^2+(IN(3)-C(3))^2-(c*(dt(3)-IN(4)))^2 ;...
(IN(1)-A(4))^2+(IN(2)-B(4))^2+(IN(3)-C(4))^2-(c*(dt(4)-IN(4)))^2 ];
D=@(IN) [2*(IN(1)-A(1)) 2*(IN(2)-B(1)) 2*(IN(3)-C(1)) 2*(c^2*(dt(1)-IN(4)));...
2*(IN(1)-A(2)) 2*(IN(2)-B(2)) 2*(IN(3)-C(2)) 2*(c^2*(dt(2)-IN(4)));...
2*(IN(1)-A(3)) 2*(IN(2)-B(3)) 2*(IN(3)-C(3)) 2*(c^2*(dt(3)-IN(4)));...
2*(IN(1)-A(4)) 2*(IN(2)-B(4)) 2*(IN(3)-C(4)) 2*(c^2*(dt(4)-IN(4)))];
x0 = Guess;
for i = 1:10
v = D(x0)\(-F(x0));
x1 = x0' + v;
x0 = x1';
end
% Error Magnification Factor
foward(1) = x0(1)-Guess(1);
foward(2) = x0(2)-Guess(2);
foward(3) = x0(3)-Guess(3);
f_error = norm(foward, inf);
b_error = c * 10^-8;
emf = f_error/b_error;
if(emf > max)
maxf = f_error;
max = emf;
maxOne = one;
end
end
x0'
maxOne'
maxf
Result = max;
I found this code, the algorithm has some interest, but I was wondering what is the language, it is a new one on me?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Matlab, I think.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page