how do I assign values to parameters in simbiology model from a .m file?

조회 수: 6 (최근 30일)
In my simbiology model, I can assign values to Species from a matlab file using the following syntax: m1.Species(5).InitialAmount = 10.0;
The above will assign 10 to the fifth species. How do I assign values using index to parameters? My model has about 14 parameters and once I try to assign a value to the 6th parameter, using following syntax, I get the following error:
m1.Parameters(6).Value = 0.01;
Index exceeds array bounds.
I appreciate your help.

채택된 답변

Arthur Goldsipe
Arthur Goldsipe 2018년 10월 26일
I'm guessing that some of your parameters are scoped to reactions.
First, some background: In SimBiology, parameters can be "scoped" either to the model or to a specific reaction. A model-scoped parameter can be used in any reaction, rule, or event in the model. A reaction-scoped parameter can only be used in the reaction that it's scoped to, and it "shadows" any model-scoped parameter of the same name. This allows you to use the same parameter name (like "kf") in multiple reactions, even if the reactions have different parameter values.
m1.Parameters only lists model-scoped parameters. To access a reaction-scoped parameter, you normally go through the reaction, for example, m1.Reactions(1).KineticLaw.Parameters(1).
As an alternative that would work for either type of parameter, you can use sbioselect to find your parameters by name. For example, to find all parameters named "kf", you could use kf = sbioselect(m1, 'Name', 'kf', 'Type', 'parameter'). If there's only one parameter named "kf", then you can set it's value with kf.Value = 10.0.

추가 답변 (0개)

커뮤니티

더 많은 답변 보기:  SimBiology Community

카테고리

Help CenterFile Exchange에서 Scan Parameter Ranges에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by