Shorthand for sbioselect/set
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Florian Augustin
el 17 de Mayo de 2018
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
1 comentario
Jim Bosley
el 17 de Mayo de 2018
Editada: Jim Bosley
el 17 de Mayo de 2018
1 comentario
Florian Augustin
el 17 de Mayo de 2018
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
Ver también
Categorías
Más información sobre Scan Parameter Ranges en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!