Documentation

Block Creation

Create new types of blocks to extend modeling functionality using MATLAB®, C/C++, and Fortran code

To extend the built-in modeling functionality provided by Simulink®, you can create custom blocks and add them to the Simulink Library Browser. You can create a custom block from a MATLAB function using a MATLAB Function, Fcn, or Interpreted MATLAB Function block.

MATLAB Function blocks enable you to use the MATLAB language to define custom functionality. These blocks are a good starting point if:

  • You have an existing MATLAB function that models the custom functionality.

  • You find it easier to model custom functionality using a MATLAB function than using a Simulink block diagram.

  • The custom functionality does not include continuous or discrete dynamic states.

You can also create custom blocks using several other methods, such as masking a subsystem of other blocks, or by incorporating C, C++, or Fortran code. To learn more about all block types, see Create Your Own Simulink Block. To compare different types of custom blocks, see Comparison of Custom Block Functionality.

  • Block Creation Basics
    Create custom blocks to extend modeling functionality
  • Block Masks
    Create customized appearance, create user–defined interface, encapsulate logic, and hide data for subsystems and custom blocks
  • Custom MATLAB Algorithms
    Create blocks that implement custom algorithms using MATLAB functions
  • Legacy Code Integration
    Integrate existing C or C++ functions, such as device drivers or external simulation code
  • S-Functions
    Define custom block functionality with MATLAB, C, C++, or Fortran code
  • FMU Importing
    Optionally use a functional mockup unit (FMU) block to bring third-party functionality into Simulink.
  • Third-Party Functionality Integration
    Integration of multiple third-party functionalities, including apps, models, and toolboxes.
  • System Object Integration
    Define System object™ for dynamic systems, include System objects in Simulink models

Featured Examples

Was this topic helpful?