Starting Release 2010a (R2010a), information regarding the various options to integrate Real-Time Workshop generated code with existing code can be obtained from the following documentation link titled 'Exporting Generated Algorithm Code for Embedded Applications':
For previous releases, read below for any additional information:
The exe file option was added for you to see that, once the Simulink portion was compiled, linked, and made into an executable file, the file works to your specifications. If you are going to embed this Simulink model into your own code, instead use the .c file that was created.
The ert_main.c file is the best file to examine. This file can act as your main file, calling the Simulink ERT code you have generated. You will see that ert_main.c file calls the generated ERT code through three main function calls:
- MODEL_INITIALIZE
- MODEL_STEP
- MODEL_TERMINATE
The ert_main.c file is well documented; follow this as an example.
Also review the ert template makefile for instructions on how to compile everything together, along with any other lib files that are required, to compile all of the ERT code with your code.
Note that the ert_main.c file and the template makefiles are located in the
$MATLAB\rtw\c\ert directory
(where $MATLAB = MATLAB root directory on your machine)
Best Answer