Integrating Code with Simulink

Prerequisites

Simulink for System and Algorithm Modeling, MATLAB Fundamentals, and knowledge of C programming

View details

Day 1 of 1
Code Integration Methods

Objective: Become familiar with the various code integration methods and discuss how a Simulink model interacts with user-defined blocks.

  • Overview of all methods of code integration
  • Introduction to S-functions
Transitioning from MATLAB to Simulink

Objective: Integrate MATLAB code into Simulink models.

  • Writing a MATLAB function in a MATLAB Function block
  • Converting a MATLAB function to a MATLAB Function block
  • MATLAB Function block coding standards
Calling External Routines

Objective: Integrate C code into a Simulink model using automated tools.

  • Calling an external C routine with the Legacy Code Tool
  • Calling an external C routine in a MATLAB Function block
Writing Wrapper S-Functions

Objective: Integrate C code into a Simulink model by manually writing C MEX S-functions.

  • Writing a C MEX S-function
  • Calling external code from a C MEX S-function
  • Work vectors
  • Inheriting input and output port dimensions
  • Additional macros
Code Generation Considerations

Objective: Explore the procedures and limitations for automatically generating code with Simulink Coder.

  • Generating code from a MATLAB Function block
  • Generating code from C MEX S-functions (Legacy Code Tool)
Code Integration Methods Review

Objective: Review code integration methods and discuss the pros and cons of each.

  • Review of all methods of code integration
  • How to choose a code integration method