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

15 次查看(过去 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
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 个评论
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