Shorthand for sbioselect/set
2 次查看(过去 30 天)
显示 更早的评论
In running simbiology models using scripts, one often wants to change parameter values. For a single parameter (e.g. "p1") we can do this:
p1_h = sbioselect(m1,'Name','p1')
p1_h.value = 15.6; % or could also use
set(p1_h,'value',15.6)
Is there a more compact method of doing this? Something like
sbiosetparval(m1,'p1_h',15.6);
I guess I can write sbiosetparval.m, but is there a native function?
0 个评论
回答(2 个)
Florian Augustin
2018-5-17
Hi Jim,
Your wrapper looks like a good solution for conveniently changing individual parameter/species/etc. properties. Thanks for sharing it on MATLAB Answers. If you need to specify multiple values for different parameter/species/compartment, then a SimBiology Variant may be useful. For completeness, here is how you can do it:
v = sbiovariant('name of variant');
addContent(v, {'Parameter', 'p1', 'Value', 15.6});
addContent(v, {'Parameter', 'p2', 'Value', 4.7});
commit(v, m1);
Admittedly, I am not sure if this qualifies as a shorthand, but it may pay off if you want to change a whole set of values.
If your use case is changing some quantities' values before simulating a model, then I would recommend using a SimFunction :
% Assuming you want to simulate a species S, without dosing,
% subject to specifying different values for parameter p1:
simFunction = createSimFunction(m1, 'p1', 'S', []);
% Simulate species S for parameter value 15.6 from time 0 to 10:
simData = simFunction(15.6, 10);
Best,
-Florian
Jim Bosley
2018-5-17
编辑:Jim Bosley
2018-5-17
1 个评论
Florian Augustin
2018-5-17
Hi Jim,
You can tell sbioselect to restrict the search to parameters:
param = sbioselect(modelObj, 'Name', varname, 'Type', 'Parameter');
This will find all parameters with matching name, including reaction-scoped parameters. If you do not want to find reaction-scoped parameters, you can replace the first input argument to sbioselect with modelObj.Parameters (assuming modelObj is not a vector of models).
Best,
-Florian
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scan Parameter Ranges 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!