MATLAB Answers

0

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

Asked by Ardeshir Goliaei on 26 Oct 2018
Latest activity Commented on by Ardeshir Goliaei on 26 Oct 2018
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.

  0 Comments

Sign in to comment.

Communities

More Answers in the  SimBiology Community

1 Answer

Answer by Arthur Goldsipe on 26 Oct 2018
 Accepted Answer

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.

  1 Comment

Yes!! Scope was the issue. It works now! Thanks so much!

Sign in to comment.