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

5 views (last 30 days)
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.

Accepted Answer

Arthur Goldsipe
Arthur Goldsipe on 26 Oct 2018
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.

More Answers (0)


More Answers in the  SimBiology Community

Community Treasure Hunt

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

Start Hunting!