How can I save my model automatically in Simulink before building it?

15 views (last 30 days)
I would like to automatically save my Simulink model and then generate code form it using Simulink Coder.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 7 Jul 2015
In the attached example, you can find how to implement this behavior in the OpenFcn Callback in Block Properties of a subsystem with the following script:
save_system(gcs);
rtwbuild(gcs);
If you double click the subsystem, it will save and then build the model.
You could also create a customization to the Simulink User Interface, by adding a new item to the Code Menu with a custom Build action. If you add the attached sl_customization.m to your MATLAB path and run "sl_refresh_customizations", it will add this new item to the Code menu and it can be started with Ctrl+Shift+B.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Tags

No tags entered yet.

Products

Community Treasure Hunt

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

Start Hunting!