Solving multiple algebraic equation

I am trying to solve 3 unknown using the following code. Am I doing this right ?
>> clear all
>> syms x y z
>> eqns=[x==(0.134+0.01*sin(z))/0.464189, 0.134*z==0.01*cos(z), y==z/x];
>> S=solve(eqns,[x y z])
Warning: Cannot solve symbolically. Returning a numeric approximation instead.
> In solve (line 303)
S =
struct with fields:
x: [1×1 sym]
y: [1×1 sym]
z: [1×1 sym]
>> S.x
ans =
0.29027727131273067299254520400093
>> S.y
ans =
0.25637661763413173595586063384135
>> S.z
ans =
0.074420304995223068940034251420538

댓글 수: 2

Walter Roberson
Walter Roberson 2019년 7월 31일
Yes, provided you want to restrict to reals.
However in this situation, you only need to solve the second equation. The z you get from that defines what x must be, and then the third equation defines y in terms of the x and z.
Aqmar Azlan
Aqmar Azlan 2019년 7월 31일
Got it ! Thank you for your help

답변 (1개)

Mahesh Taparia
Mahesh Taparia 2019년 8월 5일

0 개 추천

Hi,
Your solution is correct.
Use ‘S=vpasolve(eqns,[x y z]) ‘ instead of using ‘solve’ command, to avoid warning. Your solution is an approximate to your exact solution. By default, ‘vpa’ uses 32 significant decimal digits of precision, you can change the precision using digits command. For further information, you can refer the following link:

이 질문은 마감되었습니다.

제품

릴리스

R2016a

질문:

2019년 7월 31일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by