Solving simple symbolic trigonometry equations

42 Ansichten (letzte 30 Tage)
John
John am 28 Jan. 2016
Kommentiert: John am 2 Feb. 2016
I have a simple trigonometric equation I would like to solve, but I can't seem to get Matlab to give me an answer:
a*sin(x)-b*cos(x) = 0
I want to solve for x. This has a trivial solution and is easy to see by eye:
x = atan(b/a) and x = atan(b/a) + pi
I'd like to know whether it's possible to lead Matlab to the answer. I've tried:
syms a b x real;
solve(a*sin(x)-b*cos(x) == 0,x) % No solution
solve(a*sin(x) == b*cos(x),x) % Again, no solution
solve(a*sin(x)-b*cos(x), x) %Again no solution
All of these (and the variations I've thought of) give no solution. Any thoughts?

Antworten (1)

Vineeth Kartha
Vineeth Kartha am 2 Feb. 2016
Hi John,
Use the "solve" command as follows:
>> solve(a*sin(x) == b*cos(x),x,'IgnoreProperties',true,'ReturnConditions',true);
This returns a structure expressing the full solution.
Refer to the MATLAB documentation of solve for more information.
  1 Kommentar
John
John am 2 Feb. 2016
Hmm. Thanks for your answer. I had come across that combination, which for the sake of any other readers gives:
pi*k - (log((a + b*1i)/(a - b*1i))*1i)/2
However I was really hoping to avoid complex exponentials in the the answer (it complicates subsequent manipulation). All my variables are real-valued, and carrying along the full complex form is cumbersome.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by