Solving trigonometric equation using "solve" function.

127 visualizzazioni (ultimi 30 giorni)
Hi,
I'm trying to solve trigonometric equation as follows,
230.769*cos(x) + 153.846*sin(x) =1.715.
For this, I'm using the matlab code,
syms x;
solve(230.769*cos(x)+153.846*sin(x) == 1.715, x, 'IgnoreProperties',true, 'ReturnConditions', true);
but, in the answer structure, I couldn't find the values. The ans.x field shows that it hase 2 symbols, but there isn't any value inside them. Can you please help to find what is wrong?
Thank you.

Risposta accettata

John D'Errico
John D'Errico il 2 Lug 2019
Modificato: John D'Errico il 2 Lug 2019
Whats the problem? There is no need to set any properties anyway on such a trivial problem.
syms x;
x = solve(230.769*cos(x)+153.846*sin(x) == 1.715, x);
vpa(x)
ans =
2.1526153643152832650062014581097
- 0.97661015722014818434287396730445 - 1.8367099231598242312011508394098e-40i
The second solution is real, it just has an infinitesimal imaginary part.
And of course, you can add any multiple of 2*pi to those solutions.
But even if you do as you did, then LOOK AT THE SOLUTION THAT YOU DID GET. THINK ABOUT IT!
xsol = solve(230.769*cos(x)+153.846*sin(x) == 1.715, x, 'IgnoreProperties',true, 'ReturnConditions', true)
xsol =
struct with fields:
x: [2×1 sym]
parameters: [1×1 sym]
conditions: [2×1 sym]
>> vpa(xsol.x)
ans =
6.283185307179586476925286766559*k + 2.1526153643152832650062014581097
6.283185307179586476925286766559*k - (0.97661015722014818434287396730445 + 1.8367099231598242312011508394098e-40i)
Which says that for integer k, you can add any integer multiple of 2*pi to the solution. I'm pretty sure I said that initially.
xsol.conditions
ans =
in(k, 'integer')
in(k, 'integer')
  1 Commento
Biswajit Dipan Biswas
Biswajit Dipan Biswas il 3 Lug 2019
Thank you so much. I didn't know the application of vpa function. I appreciate your prompt help.

Accedi per commentare.

Più risposte (1)

Jaimin amin
Jaimin amin il 15 Apr 2023
sol=solve({-sin[t2+t3]-sin[t2]==-1.5 && cos[t2+t3]+cos[t2]==0.8660},{t2,t3})
  2 Commenti
Torsten
Torsten il 15 Apr 2023
Modificato: Torsten il 15 Apr 2023
syms x y real
sol=solve([sin(x+y)+sin(x)==1.5,cos(x+y)+cos(x)==0.5*sqrt(3)],[x y])
sol = struct with fields:
x: [2×1 sym] y: [2×1 sym]
sol.x
ans = 
sol.y
ans = 

Accedi per commentare.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by