필터 지우기
필터 지우기

What function (if any) can I use to simplify symbolic equation in terms of another variable?

조회 수: 13 (최근 30일)
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
Walter Roberson
Walter Roberson 2017년 6월 24일
Note: you cannot pass a cell array as the second parameter of collect(): you need to change those {} list of variables to [] lists.
Miguel Ramirez
Miguel Ramirez 2017년 6월 24일
I changed the list of variables within the braces {}, to brackets [], but I didn't see any difference. Would you mind clarifying what you meant? Thanks in advance.

댓글을 달려면 로그인하십시오.

답변 (4개)

Joshua
Joshua 2017년 6월 24일
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.
  댓글 수: 1
Miguel Ramirez
Miguel Ramirez 2017년 6월 24일
I think for the expression dH3, it will need some algebraic manipulation to achive dH3(Cv, alpha, V etc..). What I mean by this is, for the coefficient of dV1, I would need to multiply the numerator and denominator by beta, so that I may substitute Cv in the denominator (this would mean that I end up with [Cp/(beta*Cv)]dV1.
I see what you mean by the code you wrote, but this is assuming we do not need algebraic manipulation for the substitution.

댓글을 달려면 로그인하십시오.


Star Strider
Star Strider 2017년 6월 24일
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.
  댓글 수: 1
Miguel Ramirez
Miguel Ramirez 2017년 6월 24일
It would be great to have the final expression in terms of Cp and Cv, I've tried altering the code to see if I could get sys in terms of Cp and Cv and it does not work out unless I were to perform some algebraic manipulation/'trickery' by hand.
In the expression dH3, I can recognize that if I multiply the coefficient of dV1 by beta/beta, then I can substitute in Cv all while leaving in Cp (i.e., simplify the expression into a simpler one or one with a lower amount of variables).

댓글을 달려면 로그인하십시오.


John D'Errico
John D'Errico 2017년 6월 24일
편집: John D'Errico 2017년 6월 24일
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
Walter Roberson 2017년 6월 24일
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

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by