How to express a variable (function) in terms of specific variables?
28 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I wish to return r1 as a function of all the symbolic variables under syms besides the [C_S, C_CS, C_BS]. But I am not exactly sure of how I should proceed.
The code below returns 4 zero solutions, which is technically correct. But the thing is that r1 is not 0, it is a function, and thus I need a function in all the symbolic variables with known IVPs.
syms C_S C_CS C_BS C_C C_P C_B r1 r2 r3 k_A k_A1 k_S k_S1 k_D k_D1
Ct = C_S + C_CS + C_BS
func1 = k_A*C_C*C_S - k_A1*C_CS
func2 = k_S*C_CS - k_S1*C_BS*C_P
func3 = k_D*C_BS - k_D1*C_B*C_S
Eq1 = [func1 == r1, func2 == 0, func3 == 0, Ct]
KA = k_A/k_A1
KS = k_S/k_S1
KD = k_A/k_D1
[x, y, z, w] = solve(Eq1, [r1 C_S C_CS C_BS])
2 commentaires
Paul
le 26 Nov 2021
The problem defines four equations with four variables to solve for. According to solve() there is only one solution subject to a constraint. Can you show or explain mathematically, i.e., without resorting to code, what the goal is?
syms C_S C_CS C_BS C_C C_P C_B r1 r2 r3 k_A k_A1 k_S k_S1 k_D k_D1
Ct = C_S + C_CS + C_BS;
func1 = k_A*C_C*C_S - k_A1*C_CS;
func2 = k_S*C_CS - k_S1*C_BS*C_P;
func3 = k_D*C_BS - k_D1*C_B*C_S;
Eq1 = [func1 == r1, func2 == 0, func3 == 0, Ct];
sol = solve(Eq1, [r1 C_S C_CS C_BS],'ReturnConditions',true)
Réponses (1)
Paul
le 26 Nov 2021
syms C_S C_CS C_BS C_C C_P C_B r1 r2 r3 k_A k_A1 k_S k_S1 k_D k_D1
Ct = C_S + C_CS + C_BS
r1 = k_A*C_C*C_S - k_A1*C_CS;
r2 = k_S*C_CS - k_S1*C_BS*C_P;
r3 = k_D*C_BS - k_D1*C_B*C_S;
sol = solve([r2==0,r3==0],[C_CS C_S],'ReturnConditions',true)
r1 = subs(r1,[C_CS C_S],[sol.C_CS sol.C_S])
[num,den]=numden(r1)
r1 = num/den
0 commentaires
Voir également
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!