How to solve 3 TDOA equations with 3 variables x,y,z

조회 수: 14 (최근 30일)
Ebrahim Abdullah Ahmed Albabakri
편집: Torsten 2023년 11월 22일
I have a set of equations which looks like that, how to find x,y,z by coding while all other variables are known?
  댓글 수: 2
ming
ming 2023년 8월 1일
这个python函数的实现方式是?
Torsten
Torsten 2023년 8월 1일
哪個 python 函數?

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
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])
S = struct with fields:
x: (193873*83486204818584396915878923974835^(1/2))/17900867984687600000000 + 2237507060134434351121/5594021245214875000000 y: 29092239452758845515869/44752169961719000000000 - (36989*83486204818584396915878923974835^(1/2))/4475216996171900000000 z: (3723*83486204818584396915878923974835^(1/2))/11188042490429750000000 + 417333164652058423709/716034719387504000000
xnum = double(S.x)
xnum = 0.4989
ynum = double(S.y)
ynum = 0.5746
znum = double(S.z)
znum = 0.5859
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);
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
x = X(1)
x = 0.4989
y = X(2)
y = 0.5746
z = X(3)
z = 0.5859
  댓글 수: 2
Venkata Naresh
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
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
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
Torsten
Torsten 2022년 1월 21일
Then follow the two ways I gave you.
Ebrahim Abdullah Ahmed Albabakri
This is the output of solve
S =
struct with fields:
x: [1×1 sym]
y: [1×1 sym]
z: [1×1 sym]
fsolve shows an error
Error using fsolve (line 180)
FSOLVE requires the following inputs to be of data type double: 'X0'.
and This is the code
syms x1 x2 x3 x4 y1 y2 y3 y4 z1 z2 z3 z4 x y z a b c
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])

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by