How can I reinitialize my Species in the SimBiology Desktop to the final values of the last simulation in SimBiology 2.3 (R2008a)?

1 view (last 30 days)
I am doing some steady state analysis of my SimBiology model and I would like to be able to automatically reinitialize my species to have the same amounts that they had at the end of the last simulation.
Is there a way to do this automatically with the GUI brought up using SBIODESKTOP?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The ability to reinitialize your species amounts from the results of a previous simulation is not directly available in the SimBiology Desktop in SimBiology 2.3 (R2008a).
As a workaround, you can export the model and the data object from the GUI to the workspace at the end of the simulation.
In the workspace, you can use the following code as a script. Please copy and paste this code into a MATLAB file and execute it after you have exported your model and data objects from your first simulation.
%%Reinitialize Species
% model object and data object must be exported as variables 'm' and
% 'sd' respectively
%%Get the states at the final time point
finaldata = sd.Data(end,:);
names = sd.DataNames;
%%Loop through the states (species) and set their initial Amounts
numSpecies = length(names);
for c = 1:numSpecies
speciesObj = sbioselect(m,'type','species','Name',names{c});
speciesObj.InitialAmount = finaldata(c);
end
%%Run the simulation again
  1 Comment
Arthur Goldsipe
Arthur Goldsipe on 28 Sep 2015
Edited: Arthur Goldsipe on 28 Sep 2015
Hi Pau,
First, one side note: If you don't get a response to a comment, you may need to post as a new question. It's currently not easy for me to find SimBiology questions with new comments.
We hope to make it easier to do steady-state analysis in a future release. But as of R2015b, you would need to do this programmatically. You could modify the above code to something like the following:
%%Store Species steady-state values in a variant
% model object and data object must be exported as variables 'm' and
% 'sd' respectively
%%Get the states at the final time point
finaldata = sd.Data(end,:);
names = sd.DataNames;
%%Loop through the states (species) and set their initial Amounts
numSpecies = length(names);
variant = addvariant(m, 'SteadyState');
for c = 1:numSpecies
addcontent(variant, {'species', names{c}, 'InitialAmount', finaldata(c)});
end
%%Run the simulation using this variant
sd2 = sbiosimulate(m, variant);

Sign in to comment.

More Answers (0)

Communities

More Answers in the  SimBiology Community

Categories

Find more on Extend Modeling Environment in Help Center and File Exchange

Products


Release

R2008a

Community Treasure Hunt

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

Start Hunting!