Symbolic solution by matching coefficients in trigonometric equation

1 visualización (últimos 30 días)
Gabriel Droguett
Gabriel Droguett el 6 de Abr. de 2021
Comentada: Paul el 8 de Abr. de 2021
Hi, I am trying to solve the following symbolic equation:
id*cos(th) - iq*sin(th) == 2*x1*cos(th) - 2*y1*sin(th)
solving for x1 and y1 in terms of id and iq for all angles th. If considering all possible angles the solution should come from equating the coefficients of sines and cosines separetely. So I expected:
x1 = id/2
y1 = iq/2
However the solution I get is:
x1 = (id*cos(th) - iq*sin(th))/(2*cos(th))
y1 = 0
Is there an option that can be added to the solve function to handle this case?
  1 comentario
Paul
Paul el 8 de Abr. de 2021
I anticipated solve() returning three parametric solutions: one for th an odd mutiple of pi/2, one for th an even multiple of pi/2, one for th not a multiple of pi/2. However, it only returns one parametric solution:
>> sol = solve(eqn,[x1 y1],'ReturnConditions',true);
>> [sol.x1 sol.y1]
ans =
[ (id*cos(th) - iq*sin(th) + 2*z*sin(th))/(2*cos(th)), z]
>> sol.conditions
ans =
~in(th/pi - 1/2, 'integer')

Iniciar sesión para comentar.

Respuestas (1)

David Goodmanson
David Goodmanson el 6 de Abr. de 2021
Editada: David Goodmanson el 6 de Abr. de 2021
Hello Gabriel,
here is one way
syms id iq x1 y1 th1 th2
eq1 = id*cos(th1) - iq*sin(th1) == 2*x1*cos(th1) - 2*y1*sin(th1)
eq2 = id*cos(th2) - iq*sin(th2) == 2*x1*cos(th2) - 2*y1*sin(th2)
s = solve(eq1,eq2,x1,y1)
You have to persuade symbolics that the equation obtains for more than just one one angle.
  3 comentarios
John D'Errico
John D'Errico el 6 de Abr. de 2021
That is a good idea from @David Goodmanson. At the very end, add one more step to the solution, substituting th1 for th2 so you again have only one (unspecified angle.) Now your solution will be valid for what you want.
Paul
Paul el 7 de Abr. de 2021
David's solution yields:
>> [s.x1 s.y1]
ans =
[ id/2, iq/2]
What do you mean by substituting th1 for th2?

Iniciar sesión para comentar.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by