How to express a variable (function) in terms of specific variables?

7 vues (au cours des 30 derniers jours)
Andrian Mirza
Andrian Mirza le 26 Nov 2021
Réponse apportée : Paul le 26 Nov 2021
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
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)
sol = struct with fields:
r1: 0 C_S: 0 C_CS: 0 C_BS: 0 parameters: [1×0 sym] conditions: k_D*k_S + C_B*k_D1*k_S + C_B*C_P*k_D1*k_S1 ~= 0 & C_B ~= 0 & k_D1 ~= 0
Andrian Mirza
Andrian Mirza le 26 Nov 2021
Modifié(e) : Andrian Mirza le 26 Nov 2021
So, in the picture below it is solved by hand, I solved for r1, the overbar stays for S in the index in the above code. So we have three rate expressions, from which r2 and r3 are equal to 0. And the goal is to express r1 as a function of all but [C_CS, C_S C_BS]. I hope that this is a clear response from my side.

Connectez-vous pour commenter.

Réponses (1)

Paul
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
Ct = 
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)
sol = struct with fields:
C_CS: (C_BS*C_P*k_S1)/k_S C_S: (C_BS*k_D)/(C_B*k_D1) parameters: [1×0 sym] conditions: C_B ~= 0 & k_D1 ~= 0 & k_S ~= 0
r1 = subs(r1,[C_CS C_S],[sol.C_CS sol.C_S])
r1 = 
[num,den]=numden(r1)
num = 
den = 
r1 = num/den
r1 = 

Catégories

En savoir plus sur Programming 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!

Translated by