MATLAB: How can you write a hand-coded main function for generated code

codergrt_main.chandleinterruptssamplesimulinksimulink coder

How can you write a hand-coded main function for generated code, i.e using the model initialize, step and terminate functions for Simulink Coder?

Best Answer

The file grt_main.c is not present every time the code is generated from the model.
The equivalent main function classic_main.c (is present in the folder $matlabroot\rtw\c\grt\)
where $matlabroot is the location returned when you type the command 'matlabroot' in the MATLAB command window.
This file gets included automatically when the model is compiled and built using the GRT target.
You may use this particular file to interface with your external C files.