MATLAB: Accessing a simbiology class

classindexingmodel objectSimBiology

Hi to all,
I would like to access the content of the class output by the command,
msp = get(modelobj,'species')
where "modelobj" is a simbiology model object. "msp" prints as an array but I have tried several indexing conventions and none of them results in the elements of the array. This kind of array is common in simbiology and I just don't find how to access it.
Thanks in advance,
Omar

Best Answer

Hi Omar,
In the code you typed above, "msp" should be a vector of species objects that you can index using "msp(1)", "msp(2)", etc. Here is an example using a demo model included with SimBiology:
>> m1 = sbmlimport('lotka.xml')
SimBiology Model - lotka
Model Components:
Compartments: 1
Events: 0
Parameters: 3
Reactions: 3
Rules: 0
Species: 4
>> s = m1.Species; % equivalent to get(m1, 'Species')
>> s(1)
SimBiology Species Array
Index: Compartment: Name: InitialAmount: InitialAmountUnits:
1 unnamed x 1
>> s(end)
SimBiology Species Array
Index: Compartment: Name: InitialAmount: InitialAmountUnits:
1 unnamed z 0