solving equations with trigonometric functions
Show older comments
Hi, I have been trying to solve the following equations for the variables theta3 and theta4. So I wrote the code as seen below.
syms x1 x2 x3 x4 x5 x6 theta2 theta3 theta4 Ad Dd
theta2 = 119.92
x1 = 135
x2 = 25
x5 = 120
x6 = 35
Ad = 110.49467458
Dd = 9.5869687
eqn1 = x1*cos(theta2) + x2*sin(theta2) + x5*cos(theta3) -x6*cos(theta4) - Ad == 0
eqn2 = x1*sin(theta2) -x2*cos(theta2) - x5*sin(theta3) -x6*sin(theta4) - Dd ==0
S1 = solve(eqn1,eqn2)
But my output looks like this
S1 =
theta3: [2×1 sym]
theta4: [2×1 sym]
Does anyone know how do I get the answer in degrees?
I'm fairly new to Matlab, so I'm sorry if this an extremely basic question.
Regards, Harshith
4 Comments
darova
on 5 Apr 2021
I think fsolve can be better for this task. Can you explain the problem you get this equations from? Maybe there is a better way to calculate
and 
Harshith Mahesh
on 6 Apr 2021
John D'Errico
on 6 Apr 2021
You will need to seriously look at both the equations you have written, as well as the constants, since no real solution exists to the problem you have psosed. See my answer.
Bruno Luong
on 6 Apr 2021
theta2 = 119.92
degree or radian?
Do you know sin/cos argument is radian?
Accepted Answer
More Answers (2)
J Chen
on 5 Apr 2021
format long % show more digits
double(S1.theta3)
double(S1.theta4)
format % back to the default format
1 Comment
John D'Errico
on 6 Apr 2021
While this is correct as an answer, the problem itself has some major caveats that would need to be addressed. See my answer for a discussion of the problems.
darova
on 6 Apr 2021
0 votes
Here is the similar example. Maybe you will be interested
,
,
and
length are given.
angle is changing- Calculate length
and 
- Calculate
vector - Rotate
by
degree, make it of
length

See code attached
Categories
Find more on Formula Manipulation and Simplification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
