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

조회 수: 27(최근 30일)
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
Andrian Mirza
Andrian Mirza 2021년 11월 26일
편집: Andrian Mirza 2021년 11월 26일
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.

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

답변(1개)

Paul
Paul 2021년 11월 26일
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 = 

범주

Find more on Symbolic Math Toolbox in Help Center and File Exchange

태그

Community Treasure Hunt

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

Start Hunting!

Translated by