2
votes

I have defined the following variables

syms  DOSE TIME KA K V ETA1 THETA1 ETA2 THETA2 ETA3 THETA3 ;

After solving a differential equation I am getting some symbolic expressions one of which is shown below.

F= -(DOSE*KA*(exp(-K*TIME) - exp(-KA*TIME)))/(V*(K - KA));

I want to substitute the values of K,KA, DOSE etc. to find the numeric value of F. I tried the following to substitute the values of variables.

1) I defined all the variables

TIMEt = Data(:,2);

THETAa=THETA(1);
THETAb=THETA(2);
THETAc=THETA(3);

ETAa=ETA(1);
ETAb=ETA(2);
ETAc=ETA(3);

KA1 = THETA(1)*exp(ETA(1));
V1 = THETA(2)*exp(ETA(2));
K1 = THETA(3)*exp(ETA(3));

2) I substituted those variables using subs function.

subs(F,[DOSE, KA, V, K, TIME], [320, KA1,V1,K1, TIMEt]);

I also tried to use the eval function but both the subs and eval function didn't work (output is still the symbolic expression).

Any suggestion regarding what I am doing wrong or any alternative method is much appreciated.

Thanks

1

1 Answers

0
votes

It's working for me:

I Tried the following code sample:

syms  DOSE TIME KA K V ETA1 THETA1 ETA2 THETA2 ETA3 THETA3 ;
F= -(DOSE*KA*(exp(-K*TIME) - exp(-KA*TIME)))/(V*(K - KA));

TIMEt = 1;

THETAa=2;
THETAb=3;
THETAc=4;

ETAa=5;
ETAb=6;
ETAc=7;

KA1 = 8;
V1 = 9;
K1 = 10;

eval(subs(F,[DOSE, KA, V, K, TIME], [320, KA1,V1,K1, TIMEt]))

The following expression subs(F,[DOSE, KA, V, K, TIME], [320, KA1,V1,K1, TIMEt]) result is: (1280*exp(-8))/9 - (1280*exp(-10))/9

When applying eval: eval('(1280*exp(-8))/9 - (1280*exp(-10))/9') evaluates to 0.0413.

It might be only the ; that prevents you from seeing the result.