Issue with parameter array sorting in SimBiology after loading using sbioloadproject

1 回表示 (過去 30 日間)
emjey
emjey 2019 年 8 月 20 日
編集済み: emjey 2019 年 8 月 21 日
When I load a .sbproj the parameters are often in seemingly random order. Consider the example model 'AntibacterialPKPD.sbproj'
s1 = sbioloadproject('AntibacterialPKPD');
model = s1.m1
model.Parameters
the parameter array looks like that
SimBiology Parameter Array
Index: Name: Value: ValueUnits:
1 KC50 1 microgram/milliliter
2 Kmax 3.5 1/hour
3 B 1.5 1/hour
4 CL 1 milliliter/minute
...
Is it possible to sort it alphabetically with respect to 'Name'?
The reason I am asking is that I would like to assign selected parameters read in from a file, e.g. containing different parameter sets for 3 parameters B, k1, k2.
% paramArray = [paramSet1; ...
% paramSet2 ;...
% paramSet3]
% with
% paramSeti = {B_i, k1_i, k2_i}, i = 1,2,3
Any ideas would be very appreciated.
Best, M

採用された回答

Arthur Goldsipe
Arthur Goldsipe 2019 年 8 月 21 日
Hi,
By default, the parameters appear in this list in the order in which they were added to the model. However, you can reorder the parameters using the reorder method. For example, you could reorder the parameters "alphabetically" using the following code:
[~, newOrder] = sort(get(model.Parameters, 'Name'))
reorder(model, model.Parameters(newOrder))
I put alphabetically in quotes, because this sorts all uppercase before lowercase, as described here.
You can also find a specific parameter by name using the sbioselect function. So, regardless of the order, you could set the value of Kmax to 5 using the following code:
Kmax = sbioselect(model, 'Name', 'Kmax');
Kmax.Value = 5;
Finally, if you want to create parameter sets that can be swapped in and out for particular simulations, then you may be interested in variants. You can learn more about them and view an example on the sbiovariant reference page.
-Arthur
  1 件のコメント
emjey
emjey 2019 年 8 月 21 日
編集済み: emjey 2019 年 8 月 21 日
Thanks! After adding conversion to uppercase before sorting I get what I need with the first option, as described here:

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

その他の回答 (0 件)

コミュニティ

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

カテゴリ

Help Center および File ExchangeScan Parameter Ranges についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by