MATLAB: Do simfunctions support parameterized dosing

parameterized dosingSimBiology

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:
% https://www.mathworks.com/help/simbio/ref/repeatdoseobject.html
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);
legend('drug','A');
%%It doesn't work using simfunctions
doseTbl = dose.getTable();
simFunction = createSimFunction(model,{},{'drug'},{'drug'});
simFunction([],10,doseTbl);

Best Answer

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);