How do i calculate these 3 unknows in these Equations

2 次查看(过去 30 天)
a^2 + b^2 + a.b = x^2,
b^2 + c^2 + b.c = y^2
c^2 + a^2 + a.c = z^2,
I need to get a,b,c from given x y z values in these Equations.
I will be going to use different values of x y z and i want to change from those values time to time and i want to get a b c according to those values

采纳的回答

John D'Errico
John D'Errico 2020-1-21
编辑:John D'Errico 2020-1-21
Easy enough.
syms a b c x y z
EQ(1) = a^2 + b^2 + a*b == x^2;
EQ(2) = b^2 + c^2 + b*c == y^2;
EQ(3) = a^2 + c^2 + a*c == z^2;
abc = solve(EQ,a,b,c)
abc =
struct with fields:
a: [4×1 sym]
b: [4×1 sym]
c: [4×1 sym]
So 4 distinct solutions to this quadratic system. They are highly complex, but who cares? One big reason we use computers is to alleviate this very problem.
subs(abc.a,[x,y,z],[1 2 3])
ans =
(3*7^(1/2))/7
(3*7^(1/2))/7
-(3*7^(1/2))/7
-(3*7^(1/2))/7
subs(abc.b,[x,y,z],[1 2 3])
ans =
-(2*7^(1/2))/7
-(2*7^(1/2))/7
(2*7^(1/2))/7
(2*7^(1/2))/7
subs(abc.c,[x,y,z],[1 2 3])
ans =
(6*7^(1/2))/7
(6*7^(1/2))/7
-(6*7^(1/2))/7
-(6*7^(1/2))/7
Pick the solution that makes you happy.
  3 个评论
John D'Errico
John D'Errico 2020-1-22
Well you don't actually show what you did. You just showed the error message, and only part of it.
I showed the exact code that solves your problem, when run in MATLAB. That is, if you have the symbolic toolbox installed, for a current release. I cannot say what will happen if you do something else, or if you do not understand how to use MATLAB. I think the latter problem is where you are.
My guess is that you actually tried to execute the code that you saw. But the file that you are executing has the line:
abc=
in it.
I think that perhaps you don't understand that that was the OUTPUT from the solve statement.
Again, IF you execute the following lines:
syms a b c x y z
EQ(1) = a^2 + b^2 + a*b == x^2;
EQ(2) = b^2 + c^2 + b*c == y^2;
EQ(3) = a^2 + c^2 + a*c == z^2;
abc = solve(EQ,a,b,c)
then you will get the result that you wish to see. That result will be the variable abc.
MUHAMMED AKBULUT
MUHAMMED AKBULUT 2020-1-22
Oh okay i get that now sorry for my answer. i am new to this kind of use of matlab i thought that will be my all code to use. after this answer it is clear now thank you very much.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by