MATLAB Answers

0

App to convert Simbiology models to .sbproj files

Asked by Ivan Borisov on 17 Nov 2017
Latest activity Answered by Ivan Borisov on 23 Nov 2017
Hi, I frequently need to convert Simbiology models to .sbproj files using simple script with 'sbiosaveproject' function. I am inerested to build .exe out of this script using Matlab Compiler. However I am not sure if sbiosaveproject is supported by the Compiler. https://www.mathworks.com/products/compiler/supported/compiler_support.html Is there a way to do it?

  0 Comments

Sign in to comment.

Tags

Communities

More Answers in the  SimBiology Community

6 Answers

Answer by Arthur Goldsipe on 22 Nov 2017
 Accepted Answer

Hi Ivan,
The key questions are (1) why do you want to create an EXE app, and (2) what do you really need to accomplish with the app?
If your goal is to create .sbproj files without a full license and installation of MATLAB and SimBiology, that is not currently possible due to licensing restrictions. The compiler support page lists the restrictions on apps created with MATLAB Compiler. For SimBiology apps, we do not support .sbproj files or the models stored in such files. Instead, you must use SimBiology.export.Model objects or SimFunction objects, which must be saved in .mat files. Both of these provide the ability to simulate a model. However, you cannot build new models or change the structure of such models. (What I mean by that is you can't add or remove things like species or reactions in an app.)
If your goal is to use SimBiology functionality in an environment that does not require a license of MATLAB or SimBiology, you must write an app that uses SimBiology.export.Model objects or SimFunction objects. Here's an example .
If you goal is to automate the creation of sbproj files, you have several options for doing that, but all the options would require full license and installation of both MATLAB and SimBiology. Then, you could create an app using the App Designer. You could also create an .exe that communicates with the installation of MATLAB to run your script that create .sbproj files. You can see a list of APIs for various languages in the documentation for MATLAB Engine Applications.
Does that clear things up?

  0 Comments

Sign in to comment.


Answer by Sietse Braakman on 17 Nov 2017

Hi Ivan,
I am not sure I fully understand your situation. If your SimBiology models are not already an .sbproj, what format are the models in before you save them to .sbproj? With the .exe, is your aim to open a model and save it to .sbproj?
Kind regards,
Sietse

  0 Comments

Sign in to comment.


Answer by Ivan Borisov on 17 Nov 2017

Hi Sietse, the models are generated from code (.m file). The script (or function) I would like to turn into .exe is smth like run(<codefile>.m); sbiosaveproject sbproj_file;
Ivan

  0 Comments

Sign in to comment.


Answer by Sietse Braakman on 17 Nov 2017
Edited by Sietse Braakman on 17 Nov 2017

Hi Ivan,
Here are my thoughts:
  • If your models are "SimBiology.Model"-objects (you can hoover over the model in your workspace to confirm), you can do the following:
  1. Create an app (if you are on MATLAB 2017b, I would recommend using the App designer, rather than GUIDE). In the app:
  2. Create a button to load the script (uigetfile),
  3. once loaded, evaluate the script (eval),
  4. create a text input box to define the file name you want to use for the project,
  5. create another button that, when clicked, runs code to save the model (sbiosaveproject with the file name defined in step 4).
  6. compile the app to give you a .exe
  • If your models are MATLAB models (i.e. sets of ODEs in MATLAB, rather than a SimBiology.Model object), you could write a script that parses out your ODEs to create a SimBiology model. For instance, you could generate a species for each state in your model and assign a rate rule to each species that is defined by the right-hand side of your ODE. Once you have created this SimBiology model, you'll have a SimBiology.Model object, which you can proceed with as above.
I hope that helps. Kind regards,
Sietse

  0 Comments

Sign in to comment.


Answer by Ivan Borisov on 21 Nov 2017

Hi Sietse, Thanks for clarification!
Unfortunately I have the following issue:
'D:/MATLAB/R2017a/toolbox/simbio/simbio/sbiosaveproject.m MATLAB:depfun:req:ExcludedBy The file or function has been excluded from packaging for the "MCR" target environment'
Is there a workaround?

  0 Comments

Sign in to comment.


Answer by Ivan Borisov on 23 Nov 2017

Hi Arthur! Thanks for clarification. My goal is to convert models created as .m files to .sbproj in an environment where Matlab is not installed. I see that Compiler doesn't support such convertation.

  0 Comments

Sign in to comment.