How can I solve a system of equations that contain variables inside of trigonometric functions in MATLAB with the solve function?

3 views (last 30 days)
How can I solve a system of equations that contain variables inside of trigonometric functions in MATLAB with the solve function? I have currently written the following as my code:
syms A B C D
E = ((20/6)*B*cos(D))+(20*A*cos(C))-(6990*20/3)==0
F = 6990-(A*cos(C))-(B*cos(D))==0
G = (A*cos(90-C))+(B*cos(90-D))==0
H = (B*cos(D)/cos(C))-A==0
resulttt=solve([E,F,G,H],[A,B,C,D])
Thank you for your help, Matthew

Accepted Answer

Walter Roberson
Walter Roberson on 8 Oct 2015
You can do just like that.
But remember that sin() and cos() operate in radians, so you might want to use cosd() instead of cos().
By the way, if you switch to cosd from cos and do a bunch of manipulation:
A = 1398/cos((1/180)*C*pi)
B = 1398*sqrt(16+tan((1/180)*C*pi)^2)
D = -180*arctan((1/4)*tan((1/180)*C*pi))/pi
C = RootOf(Z*pi-180*arccos((1/4)*cos(Z)),Z)
In this last, RootOf(f(Z),Z) stands for the set of Z such that f(Z) = 0 -- the roots of the equation. There are 9 real roots for C, between 80 and 110.
  2 Comments
Matthew G
Matthew G on 9 Oct 2015
Unfortunately I still was not able to solve the system of equations by changing the trig. identities to cosd and sind as you mentioned. Also, the solve function in MATLAB did not provide me with any results. However, I appreciate you simplifying the equations, and for this I will accept your answer.
Walter Roberson
Walter Roberson on 9 Oct 2015
I proceeded by solving the first equation for A, substituting, solving the resulting second for B, substituting.
I then noticed that the new 4th equation involved only C and I solved for that, getting a RootOf, and I back-substituted that. Unfortunately the tool I was using was then not able to solve the last (third) of the equations. But it was able to solve the third for D in terms of C, so if you do that, you get the simplified equations above, together with the RootOf().
The tool I was using then flubbed getting good values for C, and I filed a bug report against the tool :( But I plotted the graph and found the approximate location of the roots. Note: if you plot the graph you might see what appears to be a root near about 72; it does not in fact quite reach 0 there, not until after 80.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!