How do I save SimBiology program results from the MATLAB command line?

I created a SimBiology model with multiple programs using the Model Analyzer app in MATLAB R2022b. I exported the program and ran it using the "runprogram" function, as described on the following documentation page:
https://www.mathworks.com/help/releases/R2022b/simbio/ug/view-run-program-code-simbiology-model-analyzer.html
After doing so, I want to save the data to my SimBiology project so I could view the results in the Model Analyzer app. I tried following the example on the "sbiosaveproject" documentation page but could not see the results when I opened the saved project in the Model Analyzer app. 
How would I instead go about saving the results to view in the Model Analyzer app?

 Accepted Answer

Unfortunately, the "sbiosaveproject" command will not work as desired in this situation. While this function will save any data in the MATLAB workspace along with your models, if you are loading a project saved at the MATLAB command line into the SimBiology Model Analyzer or Model Builder apps, only the models are preserved- other data will be lost. Thus, it is not recommended to use the "sbiosaveproject" command to save data along with the model if you would like to use the SimBiology apps later on.
Instead, you can try the following workaround: 
  1. Export the program code for all of the programs, as explained on the following page:https://www.mathworks.com/help/releases/R2022b/simbio/ug/view-run-program-code-simbiology-model-analyzer.htmlor generate a MATLAB script using the "fitproblem" function as detailed on the following documentation page:https://www.mathworks.com/help/releases/R2022b/simbio/ref/fitproblem.html
  2. From here, you can either stay in the MATLAB Command Window and save the results directly into an ordinary MAT-file, or you can import the results back into the Model Analyzer app through the "Import Data from MATLAB Workspace" option. This can be found under the "Data" button in the "Home" tab of the Model Analyzer app
The "Import Data" option allows you to import SimBiology data types such as SimData simulation results, fit results, etc., into the Model Analyzer app. The imported results, however, will be shown as standalone imported simulation/fit results without being associated to a specific program.

More Answers (0)

Communities

More Answers in the  SimBiology Community

Categories

Products

Release

R2022b

Community Treasure Hunt

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

Start Hunting!