Accessing a simbiology class

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

 採用された回答

Arthur Goldsipe
Arthur Goldsipe 2011 年 3 月 31 日

0 投票

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

3 件のコメント

Omar
Omar 2011 年 4 月 1 日
Hi Arthur,
Thanks for your answer.
The reason why I asked how to index such a variable was that I wanted to get all the species of the model in the form of 'compartment.species'. However when I tried to access the variable 'msp' or your 's' so that I can concatenate the compartment and the species with, for example,
[s(1,2),'.',s(1,3)]
I got an error instead of the expected 'unamed.x'.
I have found that,
[time, data, names] = getdata(tobj);
retrieves 'compartment.species' in the output 'name'. That is enough for me, but still, I'm puzzled by the impossibility to access 's' as a matrix, or a cell array or an structure or a dataset, which are the data types I'm familiar with. I would still like to know how to do it.
Thanks again,
Omar
Arthur Goldsipe
Arthur Goldsipe 2011 年 4 月 1 日
Hi Omar,
In my example, s is a vector of species and does not include compartments. If you have a model with multiple compartments, you can also index into the compartments. A SimBiology model does behave similarly to a nested structure. For example, you can get the second species contained in the first compartment as m1.Compartments(1).Species(2).
Are you trying to figure out the name of a species that is stored in a variable? In my example above, you can get that as s(1).Name, and the compartment containing that species is s(1).Parent, so you can get the compartment name as s(1).Parent.Name. If you want to recreate the "full" name, that's something like [s(1).Parent.Name '.' s(1).Name] (although you have to take special care if the compartment or parameter name contains special characters).
Are you trying to find a particular species in a model given it's name? You can do that with the sbioselect command:
sAll = sbioselect(m1, 'Type', 'species', 'Name', 's') % selects all species named 's'
c = sbioselect(m1, 'Type', 'compartment', 'Name', 'c') % selects compartment 'c'
sInC = sbioselect(c, 'Type', 'species', 'Name', 's') % only selects 's' in compartment 'c'
Omar
Omar 2011 年 4 月 2 日
Thanks Arthur.
This one,
[s(1).Parent.Name '.' s(1).Name]
is particularly useful for me at this point.
Omar

サインインしてコメントする。

その他の回答 (0 件)

コミュニティ

その他の回答  SimBiology コミュニティ

カテゴリ

ヘルプ センター および File ExchangeExtend Modeling Environment についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by