Solving equations for Variable/Variable

1 vue (au cours des 30 derniers jours)
Isaac Kambouris
Isaac Kambouris le 4 Sep 2021
I have a simple question but i have not been able to find a way to achive this and was looking for some help. For example if I have the following code
syms A B C D E
eqn = (A*B*C)/E == D;
Is it there a function that will allow me to solve for C/D = ?. I have tried using solve but this provides a struct variable that solve the equation for c and D aka (solves for C= and D=).
Thanks

Réponse acceptée

John D'Errico
John D'Errico le 5 Sep 2021
No reason you cannot do this:
syms A B C D E
eqn = (A*B*C)/E == D;
syms CoverD
solve(subs(eqn,C,CoverD*D),CoverD)
ans = 
  3 commentaires
John D'Errico
John D'Errico le 5 Sep 2021
Just look. Take it apart.
syms A B C D E
eqn = (A*B*C)/E == D;
syms CoverD;
Effectively, I define the variable CoverD as C/D. So if we accept that
CoverD = C/D
then multiply by D. Can you solve for C? I hope so.
So what does this substitution do?
subs(eqn,C,CoverD*D)
ans = 
It replaces C with the product CoverD*D. Now what happens to D in that expression? It effectively goes away, as long as D is not zero. And if D was zero, then what would be the meaning of the ratio C/D anyway? So we can assume D is never zero in this context.
The final solve should now be clear.
Isaac Kambouris
Isaac Kambouris le 6 Sep 2021
Ah thank you that makes a lot sense

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by