Export initial conditions of parameters​/compartme​nts/specie​s into workspace

3 ビュー (過去 30 日間)
Justine
Justine 2024 年 1 月 4 日
編集済み: Jeremy Huard 2024 年 1 月 10 日
Hello,
I have built a PBPK on Simbiology (2023b), with numerous parameters and compartments whose values are mostly defined by initial assignements. I nicely see the initial conditions in the model builder app after activating the initial conditions button in the toolbox. I usually have 1 by default in the value column and my calculated value based on the initial assignements in the initial conditions column.
However, when exporting the model to MATLAB Workspace (via Model tab > Export > Export Model to MATLAB Workspace), I cannot retrieve the initial values, but only the default 1 values appear.
Is there a way to access the initial values in the MATLAB workspace to do some calculations? (both for parameters and compartments)
Or, maybe even better, is there a way to transfer the initial conditions to values, as they remain constant ?
Thank you very much in advance!

採用された回答

Jeremy Huard
Jeremy Huard 2024 年 1 月 4 日
編集済み: Jeremy Huard 2024 年 1 月 10 日
Dear @Justine,
there is currently no built-in command line interface to get the initial conditions.
However, you could simulate the model with StopTime=0 to get these values.
I have attached an implementation of this approach (sbiogetInitialValues.m) that returns both a table and a variant with the computed initial values.
Here is an example:
s = sbioloadproject('lotka.sbproj');
modelObj = s.m1;
modelObj.Species
ans =
SimBiology Species Array Index: Compartment: Name: Value: Units: 1 unnamed x 1 2 unnamed y1 900 3 unnamed y2 900 4 unnamed z 0
% let's now add initial assignments and check the initial values
addrule(modelObj,'x = z','initialAssignment');
addrule(modelObj,'z = 100','initialAssignment');
[tableOut, variantOut] = sbiogetInitialValues(modelObj)
tableOut = 8×4 table
Type Name Property Value _______________ ________________ _________ _____ {'compartment'} {'unnamed' } {'Value'} 1 {'species' } {'x' } {'Value'} 100 {'species' } {'y1' } {'Value'} 900 {'species' } {'y2' } {'Value'} 900 {'species' } {'z' } {'Value'} 100 {'parameter' } {'Reaction1.c1'} {'Value'} 10 {'parameter' } {'Reaction2.c2'} {'Value'} 0.01 {'parameter' } {'Reaction3.c3'} {'Value'} 10
variantOut =
SimBiology Variant - Initial values (inactive) ContentIndex: Type: Name: Property: Value: 1 compartment unnamed Value 1.0 2 species x Value 100.0 3 species y1 Value 900.0 4 species y2 Value 900.0 5 species z Value 100.0 6 parameter Reaction1.c1 Value 10.0 7 parameter Reaction2.c2 Value .01 8 parameter Reaction3.c3 Value 10.0
I hope this helps.
Best regards,
Jérémy

その他の回答 (0 件)

コミュニティ

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

カテゴリ

Help Center および File ExchangeImport Data についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by