フィルターのクリア

solution of 3d nonlinear equation

12 ビュー (過去 30 日間)
ali hassan
ali hassan 2020 年 9 月 29 日
編集済み: Walter Roberson 2020 年 9 月 30 日
x_p, y_p, z_p=(4, 5, 2)
x_1, y_1, z_1=(8, 9, 5)
x_2, y_2, z_2=(2, 5, 1)
x_3, y_3, z_3=(6, 1, 3)
t_1=5.692820*10^-9
t_2=-2.924173*10^-9
t_3=-12.010097*10^-9
c=3.0*10^8
and my three equations are
eqn1 = sqrt((x(s)-x_p)^2+(y(s)-y_p)^2+(z(s)-z_p)^2)-sqrt((x(s)-x_1)^2+(y(s)-y_1)^2+(z(s)-z_2)^2)-(c*t_1)
eqn2 = sqrt((x(s)-x_p)^2+(y(s)-y_p)^2+(z(s)-z_p)^2)-sqrt((x(s)-x_2)^2+(y(s)-y_2)^2+(z(s)-z_2)^2)-(c*t_1)
eqn3 = sqrt((x(s)-x_p)^2+(y(s)-y_p)^2+(z(s)-z_p)^2)-sqrt((x(s)-x_3)^2+(y(s)-y_3)^2+(z(s)-z_3)^2)-(c*t_1)
where only x(s), y(s), z(s) are unknown are rest all are known
BEST REGARDS
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 9 月 29 日
編集済み: Walter Roberson 2020 年 9 月 29 日
Perhaps the first equation should involve t1 instead of t_1, and second equation should involve t2 instead of t_1, and the third should involve t3 instead of t_1 ? You do not use t1, t2, or t3 after you define them.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2020 年 9 月 29 日
x_p = 4; y_p = 5; z_p = 2;
x_1 = 8; y_1 = 9; z_1 = 5;
x_2 = 2; y_2 = 5; z_2 = 1;
x_3 = 6; y_3 = 1; z_3 = 3;
t1 = 5.692820*10^-9;
t2 = -2.924173*10^-9;
t3 = -12.010097*10^-9;
syms xs ys zs %our unknowns
syms c %constant not given in question
eqn1 = sqrt((xs-x_p)^2+(ys-y_p)^2+(zs-z_p)^2)-sqrt((xs-x_1)^2+(ys-y_1)^2+(zs-z_2)^2)-(c*t1);
eqn2 = sqrt((xs-x_p)^2+(ys-y_p)^2+(zs-z_p)^2)-sqrt((xs-x_2)^2+(ys-y_2)^2+(zs-z_2)^2)-(c*t2);
eqn3 = sqrt((xs-x_p)^2+(ys-y_p)^2+(zs-z_p)^2)-sqrt((xs-x_3)^2+(ys-y_3)^2+(zs-z_3)^2)-(c*t3);
sol = solve([eqn1, eqn2, eqn3], [xs, ys, zs]);
disp(sol.xs)
disp(sol.ys)
disp(sol.zs)
the values will be parameterized in c, which you indicate is a known value, but which you did not provide a value for.
There are two solutions for each variable.
You should probably re-substitute the solutions and verify that the values work, as MATLAB warns that some of the solutions produced might no be true solutions.
  12 件のコメント
ali hassan
ali hassan 2020 年 9 月 30 日
編集済み: ali hassan 2020 年 9 月 30 日
THANKYOU SO MUCH SIR. i ran the code on matlab 2019 and i have done some tweaks and i am getting the solution but i want to filter my solution
this is a set of possible solutions i get from my code.but i only need three values but i get 6 possible solutions.i know that my solution can neither be negative nor it can be complex and it should show only accepted answer after ignoring other solution
there are 6 possible solutions but only three are right. now how to use loop maybe to ignore left entries as it is negative and it should only display right entries as solution
CODE:
x_p = 4; y_p = 5; z_p = 2;
x_1 = 8; y_1 = 9; z_1 = 5;
x_2 = 2; y_2 = 5; z_2 = 1;
x_3 = 6; y_3 = 1; z_3 = 3;
c=3.0*10^8;
t1 = 5.692820*10^-9;
t2 = -2.924173*10^-9;
t3 = -12.010097*10^-9;
syms xs ys zs %our unknowns
eqn1 = sqrt((xs-x_p)^2+(ys-y_p)^2+(zs-z_p)^2)-sqrt((xs-x_1)^2+(ys-y_1)^2+(zs-z_2)^2)-(c*t1);
eqn2 = sqrt((xs-x_p)^2+(ys-y_p)^2+(zs-z_p)^2)-sqrt((xs-x_2)^2+(ys-y_2)^2+(zs-z_2)^2)-(c*t2);
eqn3 = sqrt((xs-x_p)^2+(ys-y_p)^2+(zs-z_p)^2)-sqrt((xs-x_3)^2+(ys-y_3)^2+(zs-z_3)^2)-(c*t3);
sol = solve([eqn1, eqn2, eqn3], [xs ys zs]);
m = 1;
for n = 1:length(sol.xs)
possibleSol(1,m) = double(sol.xs(n));
possibleSol(2,m) = double(sol.ys(n));
possibleSol(3,m) = double(sol.zs(n));
m= m+1;
end
Walter Roberson
Walter Roberson 2020 年 9 月 30 日
編集済み: Walter Roberson 2020 年 9 月 30 日
That is not 6 possible solutions, that is two solutions with three components each.
possibleSol(:, all(possibleSol>0 & imag(possibleSol)==0, 1))

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by