How to solve 3 TDOA equations with 3 variables x,y,z
조회 수: 14 (최근 30일)
이전 댓글 표시
I have a set of equations which looks like that, how to find x,y,z by coding while all other variables are known?
채택된 답변
Torsten
2022년 1월 21일
Code for symbolic solution:
syms x y z
x1 = 0.60; y1 = 0.00; z1 = 0.70;
x2 = 0.20; y2 = 1.30; z2 = 0.70;
x3 = 0.80; y3 = 1.05; z3 = 0.20;
x4 = 0.00; y4 = 0.25; z4 = 0.20;
a = 0.19845; b = 0.08791; c = 0.11492;
eqn1 = a==sqrt((x-x2)^2+(y-y2)^2+(z-z2)^2) - sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2);
eqn2 = b==sqrt((x-x3)^2+(y-y3)^2+(z-z3)^2) - sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2);
eqn3 = c==sqrt((x-x4)^2+(y-y4)^2+(z-z4)^2) - sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2);
S = solve([eqn1,eqn2,eqn3],[x,y,z])
xnum = double(S.x)
ynum = double(S.y)
znum = double(S.z)
Code for fsolve:
X0 = [1,1,1];
x1 = 0.60; y1 = 0.00; z1 = 0.70;
x2 = 0.20; y2 = 1.30; z2 = 0.70;
x3 = 0.80; y3 = 1.05; z3 = 0.20;
x4 = 0.00; y4 = 0.25; z4 = 0.20;
a = 0.19845; b = 0.08791; c = 0.11492;
fun=@(x,y,z)[a-(sqrt((x-x2)^2+(y-y2)^2+(z-z2)^2) - sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2)), ...
b-(sqrt((x-x3)^2+(y-y3)^2+(z-z3)^2) - sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2)), ...
c-(sqrt((x-x4)^2+(y-y4)^2+(z-z4)^2) - sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2))];
X = fsolve(@(x)fun(x(1),x(2),x(3)),X0);
x = X(1)
y = X(2)
z = X(3)
댓글 수: 2
Venkata Naresh
2023년 11월 22일
Hi, In the code you provided, what does the values a = 0.19845; b = 0.08791; c = 0.11492;
mean
Torsten
2023년 11월 22일
편집: Torsten
2023년 11월 22일
You are given four points X1, X2, X3 and X4 in three-dimensional space.
You search for a fifth point X for which
the distance difference between (X and X2) and (X and X1) is "a"
the distance difference between (X and X3) and (X and X1) is "b"
the distance difference between (X and X4) and (X and X1) is "c"
Here, a, b and c are given values.
I don't know the application behind this problem, maybe in surveying and mapping.
If you are interested, you should google "TDOA equations" from the title of the message.
추가 답변 (1개)
Torsten
2022년 1월 21일
If there are no specialized methods to solve the TDOA equations (did you take a look into the literature ?), I suggest trying
syms x1 x2 x3 x4 y1 y2 y3 y4 z1 z2 z3 z4 x y z a b c
eqn1 = a==sqrt((x-x2)^2+(y-y2)^2+(z-z2)^2) - sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2);
eqn2 = b==sqrt((x-x3)^2+(y-y3)^2+(z-z3)^2) - sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2);
eqn3 = c==sqrt((x-x4)^2+(y-y4)^2+(z-z4)^2) - sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2);
S = solve([eqn1,eqn2,eqn3],[x,y,z])
If this is not successful, use "fsolve".
댓글 수: 3
참고 항목
카테고리
Help Center 및 File Exchange에서 Numbers and Precision에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!