How do i calculate these 3 unknows in these Equations
2 ビュー (過去 30 日間)
古いコメントを表示
MUHAMMED AKBULUT
2020 年 1 月 21 日
コメント済み: MUHAMMED AKBULUT
2020 年 1 月 22 日
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
0 件のコメント
採用された回答
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
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.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Assumptions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!