Do simfunctions support parameterized dosing?

1 view (last 30 days)
The examples in the documentation regarding parameterized dosing do not use the simfunction, but I figured that it should work with simfunctions, since I didn't find anything in the documentation to indicate otherwise. But I'm not able to get the examples to work using simfunctions, using R2018b. Do simfunctions support parameterized dosing? Please find the code below for an example:
%%Example from Matlab documentation:
model = sbiomodel('simple model');
compartment = addcompartment(model,'Central',1);
compartment.CapacityUnits = 'liter';
species = addspecies(model,'drug');
species.InitialAmountUnits = 'milligram';
% Elimination rate
elimParam = addparameter(model,'kel',0.1);
elimParam.ValueUnits = '1/hour';
% Elimination reaction
reaction = addreaction(model,'drug -> null');
reaction.ReactionRate = 'kel*drug';
amountParam = addparameter(model,'A',50);
amountParam.ConstantValue = false;
amountParam.ValueUnits = 'milligram'
dose = adddose(model,'adaptive dose','repeat');
dose.Amount = 'A';
dose.TargetName = 'drug';
dose.StartTime = 0;
dose.TimeUnits = 'hour';
dose.Interval = 24;
dose.RepeatCount = 7;
weightParam = addparameter(model,'weight', 80);
weightParam.ValueUnits = 'kilogram';
scaleParam = addparameter(model,'doseAmountPerWeight',0.6);
scaleParam.ValueUnits = 'milligram/kilogram';
rule = addrule(model,'A = weight*doseAmountPerWeight','initialAssignment');
configset = getconfigset(model);
configset.StopTime = 7*24;
configset.TimeUnits = 'hour';
[time, drugAndAmount] = sbiosimulate(model,dose);
plot(time, drugAndAmount);
%%It doesn't work using simfunctions
doseTbl = dose.getTable();
simFunction = createSimFunction(model,{},{'drug'},{'drug'});

Accepted Answer

Arthur Goldsipe
Arthur Goldsipe on 5 Nov 2018
Yes, parameterized doses are supported with SimFunctions. However, you cannot change the type of parameterization after creating a SimFunction. In your example, you created a SimFunction with a dose that was not parameterized, so you cannot simulate it with a parameterized dose table.
To create a SimFunction that uses a parameterized dose, replace your input {'drug'} with a "template" dose object that is parameterized. For example, you can re-use your existing dose for this by changing the next-to-last line of code to the following:
simFunction = createSimFunction(model,{},{'drug'},dose);
  1 Comment
Abed Alnaif
Abed Alnaif on 5 Nov 2018
Thanks, I was able to get it to work with your suggestion.

Sign in to comment.

More Answers (0)


More Answers in the  SimBiology Community




Community Treasure Hunt

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

Start Hunting!