Integrating C & MATLAB with SIMULINK

This one-day course presents multiple methods for integrating code into Simulink models. The focus will be on integrating C and MATLAB®. Topics discussed will include M-file and C-MEX S-functions, Embedded MATLAB, and the Legacy Code Tool for wrapping external C functions into Simulink. This course is intended for intermediate to advanced Simulink users.

Pre-requisites
"Simulink for System and Algorithm Modeling", "MATLAB Fundamental and Programming Techniques", and knowledge of C programming.

Course Outline
Introduction
Gain a basic understanding of the methods of integrating code into Simulink and the motivations for using each method

  • Company introduction
  • Model-Based Design
  • Overview of code integration methods
  • Choosing the correct code integration method

Transitioning from MATLAB® to Simulink®
Learn about the methods of integrating M-code into Simulink

  • Writing Embedded MATLAB Functions
  • Benefits and drawbacks of Embedded MATLAB Functions
  • Converting a MATLAB function to an Embedded MATLAB Function
  • Basic S-function concepts
  • Writing M-file S-functions
  • Benefits and drawbacks of M-file S-functions
  • Level-1 versus Level-2 M-file S-functions
  • Converting a MATLAB function to an M-file S-function

Calling External C Functions and Routines
Learn about the methods of integrating C code into Simulink

  • Calling an external C routine using the Legacy Code Tool
  • Benefits and drawbacks of using the Legacy Code Tool
  • Writing an S-function using the S-Function Builder
  • Benefits and drawbacks of using the S-Function Builder
  • Calling an external C routine using the S-Function Builder

Code Generation Considerations
Learn the procedures and limitations for automatically generating code with Real-Time Workshop® when using the code integration methods described in the course

  • Process for generating code from an Embedded MATLAB Function
  • Limitations for generating code from an Embedded MATLAB Function
  • Limitations for generating code from M-file S-functions
  • Legacy Code Tool options that facilitate code generation
  • S-Function Builder options that facilitate code generation
  • Limitations for generating code from the S-Function Builder