MATLAB & Simulink


Integrating Code with Simulink

Course Highlight

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

Course Objectives

The aim of the course is to provide knowledge on writing M-file and C MEX S-functions, wrapping external C functions code using Legacy Code Tool and using Embedded Matlab.

Who Must Attend 

Engineers, scientist and researchers who wish to integrate applications written in C into Simulink model.

Course Benefits



Upcoming Program

xilinx ATP 黑.png

Techsource Systems is
Mathworks Sole and Authorised Distributor and Training Partner

Upon the completion of this course, the participants will be able to design integrated Simulink model with C and Embedded Matlab.


”Comprehensive SIMULINK” and “Comprehensive MATLAB“ or equivalent experience using MATLAB and SIMULINK, and knowledge of C programming.

Course Outline

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