Simlify a function in matlab

3 vues (au cours des 30 derniers jours)
Mtnkh
Mtnkh le 23 Jan 2023
Commenté : Mtnkh le 24 Jan 2023
Hi,
there is an equation:
cos(x) + B*sin(x) = C
and also an expression:
-sin(x) + B*cos(x)
I want to know if we can rewirte the expression in a way to omit "x". I could't do it manually. I wanted to know if there is any way in Matlab.
Thanks
  2 commentaires
Benjamin Thompson
Benjamin Thompson le 23 Jan 2023
So you want to solve the equation for 'x'?
Mtnkh
Mtnkh le 24 Jan 2023
Yes!

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 23 Jan 2023
syms B C x
eqn = cos(x) + B*sin(x) == C
eqn = 
expr = -sin(x) + B*cos(x)
expr = 
xsol = solve(eqn,x)
xsol = 
newexpr = simplify(subs(expr, x, xsol))
newexpr = 
  1 commentaire
Walter Roberson
Walter Roberson le 23 Jan 2023
Two solutions.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by