Finding the solution of a system of equations

조회 수: 7 (최근 30일)
Steewz
Steewz 2020년 6월 18일
댓글: Kshitij Chhabra 2020년 6월 22일
Hey i would like to find the solutions for this system assuming that my unknows are X Y and Z
solve doesnt work
syms X Y Z
eq1=sqrt((a1-X)^2+(b1-Y)^2+(c1-Z)^2) == D1+R1;
eq2=sqrt((a2-X)^2+(b2-Y)^2+(c2-Z)^2) == D2+R2;
eq3=sqrt((a3-X)^2+(b3-Y)^2+(c3-Z)^2) == D3+R3;
eq4=sqrt((a4-X)^2+(b4-Y)^2+(c4-Z)^2) == D4+R4;
TY

답변 (1개)

Kshitij Chhabra
Kshitij Chhabra 2020년 6월 18일
Hi Steewz,
From the question, I understand that you want to solve the given set of quadratic equations for X,Y,Z. Since not specified in the question, I am assuming the other variables as constants which can be specified later(or you can assign them to be syms variable too).
For the above problem you may try using solve function in the following way:
sol = solve([eq1, eq2, eq3], [X, Y, Z]);
For accessing the results you may use:
sol.X;
sol.Y;
sol.Z;
  댓글 수: 2
Steewz
Steewz 2020년 6월 18일
Hi,
Thank you for your answer, yes you are right the other variables are constants which are determined earlier in my code, i've already tried the solution you proposed and it works, but it's only with 3 equations, I want to solve the system with 4 equations, and this is the problem xD
Kshitij Chhabra
Kshitij Chhabra 2020년 6월 22일
Hi,
Writing the above code as:
sol = solve([eq1, eq2, eq3,eq4], [X, Y, Z]);
should solve the problem too, If it's giving some unexpected behavior it'd be helpful if you could share the values of constant as well.

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

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by