Shorthand for sbioselect/set
조회 수: 3 (최근 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!