How to simplify two symbolic equations and ensure selected variables are not contained in the equation?
Mostra commenti meno recenti
I am a beginner in MatLab and I need some advice. My goal is to come up with an equation for x0 that does not contain h0 and an equation for h0 that does not contain x0. How can I get MatLab to do this automatically?
I have given it a try as below, but the equations I obtained are different from the ones I obtained by hand.
syms x0 h0
[x0 h0] = solve ('(a/2)*(0-x0)^2-h0=0', '(a/2)*(L-x0)^2-h0-h=0')
x0 =
(L^2*a)/2 + 2^(1/2)*L*a*(h0/a)^(1/2)
(L^2*a)/2 - 2^(1/2)*L*a*(h0/a)^(1/2)
h0 =
-2^(1/2)*(h0/a)^(1/2)
2^(1/2)*(h0/a)^(1/2)
By hand I can get the following:
x0 = L/2 - h/(a*L) --(a) h0 = a*L^2/8 + h^2/(2*a*L^2)-h/2 -- (b)
What MatLab commands should I use to get the equations (a) and (b) I determined manually?
Thanks!
Risposte (2)
Mischa Kim
il 30 Gen 2015
FallGuy, use instead
syms x0 h0
[x0 h0] = solve('(a/2)*(0-x0)^2-h0=0', '(a/2)*(L-x0)^2-h0-h=0',x0,h0)
x0 =
-(- a*L^2 + 2*h)/(2*L*a)
h0 =
(L^4*a^2 - 4*L^2*a*h + 4*h^2)/(8*L^2*a)
Note the additional inputs x0 and h0 in the solve command.
1 Commento
Mischa Kim
il 2 Feb 2015
In the command window run:
clear % remove all vars from workspace
syms x0 h0
[x0 h0] = solve('(a/2)*(0-x0)^2-h0=0', '(a/2)*(L-x0)^2-h0-h=0',x0,h0)
Copy-paste the above code to make sure you are running the exact same commands.
Also, please add follow-up questions as comments for better readability.
Categorie
Scopri di più su Common Operations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!