MATLAB Answers

How do i calculate these 3 unknows in these Equations

26 ビュー (過去 30 日間)
MUHAMMED AKBULUT
MUHAMMED AKBULUT 2020 年 1 月 21 日 14:28
コメント済み: MUHAMMED AKBULUT 2020 年 1 月 22 日 11:11
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 件のコメント

サインイン to comment.

採用された回答

John D'Errico
John D'Errico 2020 年 1 月 21 日 14:59
編集済み: John D'Errico 2020 年 1 月 21 日 14:59
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 件のコメント

MUHAMMED AKBULUT
MUHAMMED AKBULUT 2020 年 1 月 22 日 7:36
Error: File: Test.m Line: 7 Column: 7
Invalid expression. Check for missing or extra characters.
This is the error i got when i try to run this text.
Line 7 refers to this part:
abc=
I need to get the a,b and c from x y z values.
John D'Errico
John D'Errico 2020 年 1 月 22 日 9:28
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 日 11:11
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.

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。

製品


リリース

R2019a

Translated by