I cannot figure out how to solve for k1, k2, k3, k4 simultaneously using the values for the variable listed in the table.

7 Comments

Look up help on fminsearch.
Provide a Matlab worksheet with your initial attempt.
Post the code written to solve this.
It is actually straightforward, however there are some subtleties involved when coding to solve a matrix of dependent variables.
Here is the text version of the script as well. Thanks in advance. I am new to using matlab.
t = 10; GnGn0 = 9.1; GnGn = 5.4; GnG = 2.9; GGn = 0.5; GG = 0.2;
syms a b c d
eqns = [ GnGn == GnGn0 * (exp(-(a + b)*t)), GnG == ((a*GnGn0)/(c-(a+b)))*((exp(-(a+b)*t))-exp(-c*t)), GGn ==(b*GnGn0/d-(a+b))*(exp(-(a+b)*t)-exp(-d*t)), GG == c*a*GnGn0/ c-(a+b)*(exp(-(a+b)*t)/(-(a+b))+(exp(-c*t))/(-(a+b))+(exp(-c*t)/c)+(1/(a+b))-(1/c)+((d*GnGn0)/(d-(a+b))*(exp(-(a+b)*t)/-(a+b))+(exp(-d*t))/d)+1/(a+b)-1/d)];
S = solve (eqns, [a b c d] )
Coding the left-hand-side (LHS) is not necessary, and is actually in error.
For example, the first equation, instead of being:
GnGn == GnGn0 * (exp(-(a + b)*t))
would be more appropriately coded as:
k(5) .* exp(-(k(1) + k(2)).*t)
since the parameters to be estimated need to be passed as a vector. They are already appropriately referred to in this context. The LHS is implicitly provided in the regression, providing that the columns of the regression match the columns in the dependent variables matrix.
Please re-code them as a function of the parameters and independent vairable, and provide the dependent variable matrix and the independent fairable vector (‘Time’).
They can be coded as an anonymous function, and the function arguments shoud be ‘k’ and ‘t’, for example with respect to the first equation:
Geqn = @(k,t) [k(5) .* exp(-(k(1) + k(2)).*t)]
The kinetic parameters are ‘k(1)’ through ‘k(4)’ so additional parameters to be estimated are ‘k(5)’ through ‘k(8)’ and correspond to ‘GnGn’ to ‘GG’. Here, ‘k(5)’ is ‘GnGn’ and is to be estimated as a parameter.
I leave the coding of the equations and the matrix to you.
.
I am still struggling to solve this. here is my latest attempt; it is saying error, undefined 'k'
GnGn0 = 9.1; k(5) .* [5.4 3.5 2.4 1.8 1.6 1.8]; k(6) .* [2.9 4.2 4.8 4.8 4.6 4.3]; k(7).* [0.5 0.7 1.0 1.2 1.2 0.9]; k(8).* [0.2 0.6 1.0 1.3 1.7 2.1]; t = 10;
k(5) .* exp(-(k(1) + k(2)).*t);
k(6) .* ((k(1)*GnGn0)/(k(3)-(k(1)+k(2))))*((exp(-(k(1)+k(2))*t))-exp(-k(3)*t));
k(7) .* (k(2)*GnGn0/k(4)-(k(1)+k(2)))*(exp(-(k(1)+k(2))*t)-exp(-k(4)*t));
k(8) .* k(3)*k(1)*GnGn0/ k(3)-(k(1)+k(2))*(exp(-(k(1)+k(2))*t)/(-(k(1)+k(2)))+(exp(-k(3)*t))/(-(k(1)+k(2)))+(exp(-k(3)*t)/k(3))+(1/(k(1)+k(2)))-(1/k(3))+((k(4)*GnGn0)/(k(4)-(k(1)+k(2)))*(exp(-(k(1)+k(2))*t)/-(k(1)+k(2)))+(exp(-k(4)*t))/k(4))+1/(k(1)+k(2))-1/k(4));
Gzeroeqn = @(k,t) [k(5) .* exp(-(k(1) + k(2)).*t)]
GoneLeqn = @(k,t) [k(6).* ((k(1)*GnGn0)/(k(3)-(k(1)+k(2))))*((exp(-(k(1)+k(2))*t))-exp(-k(3)*t))]
GoneReqn = @(k,t) [k(7) .* (k(2)*GnGn0/k(4)-(k(1)+k(2)))*(exp(-(k(1)+k(2))*t)-exp(-k(4)*t))]
Gtwoeqn = @(k,t) [k(8) .* k(3)*k(1)*GnGn0/ k(3)-(k(1)+k(2))*(exp(-(k(1)+k(2))*t)/(-(k(1)+k(2)))+(exp(-k(3)*t))/(-(k(1)+k(2)))+(exp(-k(3)*t)/k(3))+(1/(k(1)+k(2)))-(1/k(3))+((k(4)*GnGn0)/((k(4))-(k(1)+k(2)))*(exp(-(k(1)+k(2))*t)/-(k(1)+k(2)))+(exp(-k(4)*t))/k(4))+1/(k(1)+k(2))-1/k(4))]
Hi Lindsay,
To assist you effectively, it would be helpful to know the specific problem that you're encountering. Your code is able to provide a set of solution when executed.
t = 10; GnGn0 = 9.1; GnGn = 5.4; GnG = 2.9; GGn = 0.5; GG = 0.2;
syms a b c d
eqns = [ GnGn == GnGn0 * (exp(-(a + b)*t)), GnG == ((a*GnGn0)/(c-(a+b)))*((exp(-(a+b)*t))-exp(-c*t)), GGn ==(b*GnGn0/d-(a+b))*(exp(-(a+b)*t)-exp(-d*t)), GG == c*a*GnGn0/ c-(a+b)*(exp(-(a+b)*t)/(-(a+b))+(exp(-c*t))/(-(a+b))+(exp(-c*t)/c)+(1/(a+b))-(1/c)+((d*GnGn0)/(d-(a+b))*(exp(-(a+b)*t)/-(a+b))+(exp(-d*t))/d)+1/(a+b)-1/d)];
S = solve (eqns, [a b c d] )
Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve.
S = struct with fields:
a: 0.052718795965041138787084947058991 b: -0.00053124996978357303149771178071696 c: 0.048496912955408590423104924976659 d: 0.0037217687458454391313963030682866
There is only one warning that MATLAB is not able to provide solution sybolically, but it is providing a numerical solution.

Sign in to comment.

Answers (0)

Products

Asked:

on 5 Feb 2022

Edited:

on 11 Jan 2024

Community Treasure Hunt

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

Start Hunting!