How do I convert a .m script to .sbproj file?

6 views (last 30 days)
I have both Simbiology and MATLAB installed on my machine. I have implemented a SimBiology model using MATLAB code, which is saved as a .m file. I would like to save or convert this model to a .sbproj file. Is there a way to achieve this?
I am trying to do this because we simulate our model using a MATLAB script. This script defines all of the modeling parameters, including an SSA solver and triggering events. Our previous model was implemented using the SimBiology Graphical User Interface. We have made a similar model using SimBiology Command Line. The model we created is somewhat similar to what is shown here: We want to simulate the new model that was created from the SimBiology Command Line using our simulation script. However, this requires the SimBiology model to be saved in .sbproj format. Any ideas on how this could be achieved would be much appreciated.
Thank you!

Accepted Answer

Joe Myint
Joe Myint on 23 May 2018
Hi Colton,
You can use the sbiosaveproject function to save the SimBiology model (and data) to a .sbproj file. For example,
model = sbmlimport ('oscillator.xml');
simData = sbiosimulate(model);
sbiosaveproject oscillator.sbproj model simData;
Hope it helps, Joe
  1 Comment
Y.K. on 29 May 2023
Edited: Y.K. on 30 May 2023
Hi, Joe
I could not see the saved 'simData' in the 'oscillator.sbproj' which had been generated and saved using your sample code.
What was wrong with the procedure?
The 'oscillator.sbproj' file was created from the command window of Matlab 2019b.
I checked the 'simData' using the GUI of Simbiology Model Analyser for Matlab 2019b.

Sign in to comment.

More Answers (1)

Joe Myint
Joe Myint on 30 May 2023
Hi Y.K.,
Opening the SBPROJ directly in the SimBiology Model Analyzer app will not automatically load the simData that was saved previously at the command line. To import the simData, you need to do these additional steps:
  1. At the command line, enter: sbioloadproject("oscillator.sbproj"). You should get model and simData loaded in the workspace as variables.
  2. Enter: simBiologyModelAnalyzer("oscillator.sbproj"). The app opens and "model" is loaded in the app.
  3. On the Home tab of the app, select Data > Import Data from MATLAB workspace. Select simData. Click OK. simData is now loaded in the app in a separate folder, such as Data1.
Hope it helps,
Joe Myint
Joe Myint on 31 May 2023
Edited: Joe Myint on 31 May 2023
I am not so sure what you are trying to do. You can use sbiosaveproject and add the model and simulation data to the project using:
sbiosaveproject oscillator.sbproj model simData;
However, it sounds like you are trying to ask if there is a command line way to imitate the tasks that you would normally do in the app? If so, there is no command line function to do the task described in step 3. Step 1 and step 2 are already the command line function/way.
Having said that, you can generate code for modeling-specific actions and analysis programs from the apps. Take a look at these examples to see if they might be helpful.

Sign in to comment.


More Answers in the  SimBiology Community

Community Treasure Hunt

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

Start Hunting!