What function (if any) can I use to simplify symbolic equation in terms of another variable?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165470/image.jpeg)
I would like dH3 in terms of Cv
Edit: I see that I have caused a bit of confusion here. What I meant to say was, I would like dH3 in terms of both Cp and Cv. I can achieve this by hand manipulation. For example, if we multiply the coefficient of dV1 by beta/beta then we can rewrite the coefficient as Cp/(Cv*beta). This produces a simpler expression by simply multiplying the numerator and denominator by beta and substituting in Cv. I hope this helps.
4 comentarios
Walter Roberson
el 24 de Jun. de 2017
Note: you cannot pass a cell array as the second parameter of collect(): you need to change those {} list of variables to [] lists.
Respuestas (4)
Joshua
el 24 de Jun. de 2017
If you define your variables using the 'syms' function, you can create equations that will simplify. For example, the code
syms a b c d e
b=d*e
a=b+c
will give the following output
b =
d*e
a =
c + d*e
showing that the equation b=d*e was automatically plugged into the equation a=b+c. You can do something similar for your two equations. Just make sure to put the second equation in the form cp= and put it before your larger equation.
Star Strider
el 24 de Jun. de 2017
Looking at your equations (specifically in ‘T4_5.m’), the only way I can see to cast them in terms of ‘Cv’ is to solve the last equation for ‘Cp’, the substitute in the rest of them:
Eqn = Cv == Cp - (T*V*alpha^2)/beta;
Cpv = solve(Eqn, Cp);
sys = [dV; dS; dU; dH; dF; dG];
sys = simplify(subs(sys, Cp, Cpv), 'Steps',10)
This gives:
sys =
V*(alpha*dT - beta*dP)
(dT*((T*V*alpha^2)/beta + Cv))/T - V*alpha*dP
dT*((T*V*alpha^2)/beta - P*V*alpha + Cv) + V*dP*(P*beta - T*alpha)
dT*((T*V*alpha^2)/beta + Cv) - V*dP*(T*alpha - 1)
P*V*beta*dP - dT*(S + P*V*alpha)
V*dP - S*dT
leaving you with the slightly boring task of having to re-define ‘dV’*, ‘dS’, ‘dU’, ‘dH’, ‘dF’, and ‘dG’ in terms of the elements of ‘sys’. This would give your final result as a function of ‘Cv’ (and other variables).
If I understand correctly what you want to do, this could work. If not, at least it may suggest an approach to a solution.
John D'Errico
el 24 de Jun. de 2017
Editada: John D'Errico
el 24 de Jun. de 2017
I would just use subs. Without running your scripts, this will work:
dH3 = subs(dH3,Cp,Cv + T*V*alpha/beta)
Now the entire expression will be in terms of Cv. You might want to do some simplification, but that comes after the substitution. I could have picked some other variable to use for the substitution.
Walter Roberson
el 24 de Jun. de 2017
In R2017a or later, instead of
solve(dH3, Cp) %implicit is dH3 == 0
isolate(dH3 == 0, Cp) %the == 0 must be made explicit
"The result is similar to solving eqn for expr. If isolate cannot isolate expr, it moves all terms containing expr to the left side."
isolate() is a bit more flexible in cases where getting a complete solution might be difficult
0 comentarios
Ver también
Categorías
Más información sobre Conversion Between Symbolic and Numeric en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!