solve not returning answers

2 vues (au cours des 30 derniers jours)
RH
RH le 9 Mar 2023
Commenté : RH le 9 Mar 2023
Hi. I'm having touble solving this set of equations in Matlab.
syms a b;
eq1=2==cos(a)+(3/5)*sqrt(5)*cos(b);
eq2=0==sin(a)+(3/5)*sqrt(5)*sin(b);
eqns=[eq1, eq2];
solve(eqns,[a b])
ans = struct with fields:
a: [2×1 sym] b: [2×1 sym]
The answers should be 36.9 and -26.6 degrees. But I cannot get this with solve. Any feedback is appreciated. Thanks!

Réponse acceptée

Sarvesh Kale
Sarvesh Kale le 9 Mar 2023
Hi RH,
I think you have to index into the answer since the ans variable is a struct, try the following
syms a b;
eq1=2==cos(a)+(3/5)*sqrt(5)*cos(b);
eq2=0==sin(a)+(3/5)*sqrt(5)*sin(b);
eqns=[eq1, eq2];
x = solve(eqns,[a b]);
disp(x.a)
disp(x.b) % indexing into x
I hope this solves your query
Thank you
  1 commentaire
RH
RH le 9 Mar 2023
Thank you Sarvesh!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Tags

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by