MATLAB: Can I separate or split large generated files into smaller files created by Simulink Coder 8.0 (R2011a)

12codecoderembeddedfilereleasertwsimulink codersplit

For my model, the size of the files generated by Simulink or Embedded coder is very large. This is too big for my compiler to handle. Is there any way to force the embedded coder to create multiple files as its output, rather than put every function in the same C file. Ideally I would like to put certain subsystems in a different C file. Can I split these large files into files of smaller sizes using Simulink Coder?

Best Answer

The generated code can be separated into different files if the model architecture is modular. Some approaches would be:
1) Create nonvirtual subsystems and set the option to create a separate function. Right click on the subsystem, and then select the Code Generation tab. Next you will want to select Function Packaging: Function. You can then specify the Function name and the File name as the same as the subsystem name, or you can have a user defined name. For further details on these subsystem options, please refer to:
>> web([docroot,'/toolbox/rtw/ug/f1127051.html#f1030128'])
2) Use model reference, in this way the main file will call the others
3) If you are using Simulink data objects, you can specify the header file for your data. For example, if you are using a Simulink.Bus object, you can specify to export the data type definition to a separate header file. For the bus case, refer to Data scope in: