Generated C code inspection helps you check the code created automatically from Simulink models. It ensures the code works as expected and is easy to understand.
Generated C code inspection in Simulink
1. Open your Simulink model. 2. Configure code generation settings. 3. Generate C code using Simulink Coder. 4. Use the Code Inspector tool to review the generated code. 5. Navigate through code files and compare with model elements.
The Code Inspector is a graphical tool inside Simulink for easy code review.
You can link code sections back to model blocks for better understanding.
simulink_model = 'my_model';
rtwbuild(simulink_model);open_system('my_model'); set_param('my_model', 'GenerateCodeOnly', 'on'); rtwbuild('my_model');
codeInspector('my_model_ert_rtw');This example opens a Simulink model called 'simple_model', sets it to generate embedded C code only, builds the code, then opens the Code Inspector to review the generated files.
model = 'simple_model'; open_system(model); set_param(model, 'SystemTargetFile', 'ert.tlc'); set_param(model, 'GenerateCodeOnly', 'on'); rtwbuild(model); codeFolder = [pwd filesep model '_ert_rtw']; codeInspector(codeFolder);
Always check that your model is error-free before generating code.
Use the Code Inspector to trace code back to model blocks for easier debugging.
Generated code may be complex; focus on key functions and variables related to your model.
Generated C code inspection helps verify and understand code from Simulink models.
Use Simulink Coder and Code Inspector tools to generate and review code.
Inspecting code ensures correctness and helps optimize embedded system software.