How to substitute one equation into another ?
75 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rodrigo Pena
am 24 Nov. 2021
Beantwortet: Cris LaPierre
am 29 Dez. 2021
Hello all, how are you?
I have 3 equations to solve 3 unknowns (v , b and h). I would like to solve equation 4 for the variable 'b' and plug in to equations 6 and 7. Then I will have 2 new equations ( Equations 9 and 10 ) for two unknowns (v, h). Finally I would like to find values for v and h.
I managed to do the 2 first steps but I am not able to do the final (find values of v and h) I will leave a picture for better understanding:
All the other variables ( E, t, P and x) will be replaced by constants.
This is the code I have so far:
syms v h b t E x P u s
assume(h,'positive')
assume(b,'positive')
assume(t,'positive')
assume(E,'positive')
assume(x,'positive')
assume(P,'positive')
A = 2*h*t + 2*t*(b - 2*t);
I = (b*h^3)/12 - ((b -2*t)*(h-2*t)^3)/12;
G1 = (P*x*h)/(4*I) - 180;
G2 = (P*x^3)/(48*E*I) - 40;
Lagrangian = A + u*(G1 + s^2) + v*G2;
dLdh = diff(Lagrangian,h);
dLdb = diff(Lagrangian,b);
dLdu = diff(Lagrangian,u);
dLdv = diff(Lagrangian,v);
dLds = diff(Lagrangian,s);
Eq1 = dLdh == 0;
Eq2 = dLdb == 0;
Eq3 = dLdu == 0;
Eq4 = dLdv == 0;
Eq5 = dLds == 0;
Eq6 = subs(Eq1,u,0);
Eq7 = subs(Eq2,u,0);
Eq8 = solve(Eq4,b);
Eq9 = subs(Eq6,b,Eq8);
Eq10 = subs(Eq7,b,Eq8);
Thank you so much !
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 29 Dez. 2021
Eliminate scalar variables from an equation by using the variable's value from another equation. In the second equation, isolate the variable on the left side using isolate, and then substitute the right side with the variable in the first equation.
First, declare the equations eqn1 and eqn2.
syms x y
eqn1 = sin(x)+y == x^2 + y^2;
eqn2 = y*x == cos(x);
Isolate y in eqn2 by using isolate.
eqn2 = isolate(eqn2,y)
Eliminate y from eqn1 by substituting the right side of eqn2 with the left side of eqn2 in eqn1.
eqn1 = subs(eqn1,lhs(eqn2),rhs(eqn2))
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!