Simbiology: Generate reactions with a loop
이전 댓글 표시
I'm creating a pk model with the following reaction rate: 'Dose*ka*e^(-ka*(time-TimeOfDose))'. I haven't been able to figure out how to do this in Simbiology, other that to just create an absorbance reaction for each dose. However, I need a lot of doses, and to be able to easily change the number of doses. I figured that I would use a loop to generate the correct number of reactions, however I'm getting some errors when trying this.
Here is the code:
for i = 0:(nDose - 1)
r(i) = addreaction(m1, 'null -> Central.Drug');
set(r(i), 'ReactionRate', Dose*ka*e^(-ka*(time-(i*7)));
end
With 7 being the dosing interval. This gives the error:
Subscript indices must either be real positive integers or logicals.
답변 (1개)
Arthur Goldsipe
2017년 10월 2일
0 개 추천
The immediate problem is that MATLAB uses 1-based indexes when indexing into vectors, so you need to make sure that you start at r(1) instead of r(0).
But it sounds like you're trying to model first-order absorption of a drug. There is a simpler way to do that in SimBiology. Basically, add an intermediary species and reaction to your model to account for the first order absorption. For example, if you call the species Dose and put the species in compartment Central, then add a reaction "Central.Dose -> Central.Drug" with reaction rate "ka*Central". Finally, implement your dosing using a dose object with "Dose" as the target.
댓글 수: 2
Colin Cess
2017년 10월 6일
Arthur Goldsipe
2017년 10월 10일
I guess I still don't understand why you want to use the analytical/explicit solution to differential equations with SimBiology. I'll show you one way that uses events below. But I think it's going to be a lot more complicated than just letting SimBiology solve the equations for you. If you have additional follow-up questions, I suggest contacting me through my profile page. I don't get notified when you post a comment here.
m1 = sbiomodel('m1');
m1.addparameter('Dose', 2.0);
m1.addparameter('ka', 0.1);
m1.addparameter('doseTerm', 0.0, 'ConstantValue', false);
m1.addrule('doseTerm = Dose', 'initialAssignment'); % t0 dose
r1 = m1.addreaction('null -> Central.Drug');
r1.ReactionRate = 'doseTerm*ka*exp(-ka*time)';
m1.addparameter('doseInterval', 7);
m1.addparameter('doseCounter', 1, 'ConstantValue', false);
m1.addparameter('nDose', 3);
m1.addevent('time > doseCounter*doseInterval && doseCounter < nDose', ...
{'doseTerm = doseTerm + Dose*ka*exp(ka*doseCounter*time)', ...
'doseCounter = doseCounter + 1'});
커뮤니티
더 많은 답변 보기: SimBiology Community
카테고리
도움말 센터 및 File Exchange에서 Scan Parameter Ranges에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!