This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

MATLAB System Block

Why Use the MATLAB System Block?

System objects let you implement algorithms using the MATLAB® language. The MATLAB System block enables you to use System objects in Simulink®.

The MATLAB System block lets you:

  • Share the same System object™ in MATLAB and Simulink

  • Dedicate integration of System objects with Simulink

  • Unit test your algorithm in MATLAB before using it in Simulink

  • Customize dialog box customization

  • Simulate efficiently with better initialization

  • Handle states

  • Customize block icons with port labels

  • Access two simulation modes

Choosing the Right Block Type

There are several mechanisms for including MATLAB algorithms in Simulink, such as:

  • MATLAB System block

  • MATLAB Function block

  • Interpreted MATLAB Function block

  • Level-2 MATLAB S-Function block

  • Fcn block

For help on choosing the right block, see Comparison of Custom Block Functionality.

System Objects

Before you use a MATLAB System block, you must have a System object to associate with the block. A System object is a specialized kind of MATLAB class. System objects are designed specifically for implementing and simulating dynamic systems with inputs that change over time.

For more information on creating System objects, see Customize System Objects for Simulink.


To use your System object in the Simulink environment, it must have a constructor that you can call with no arguments. By default, the System object constructor has this capability and you do not need to define your own constructor. However, if you create your own System object constructor, you must be able to call it with no arguments.

System objects exist in other MATLAB products. MATLAB System block supports only the System objects written in the MATLAB language. In addition, if a System object has a corresponding Simulink block, you cannot implement a MATLAB System block for it.

Interpreted Execution or Code Generation

You can use MATLAB System blocks in Simulink models for simulation via interpreted execution or code generation.

Default Input Signal Attributes

If a MATLAB System block has one or more inputs that are unconnected to another block’s output port or connected to a port that has underspecified attributes, the default input signal attributes for the unspecified attributes are:

Data AttributeDefault
Data Typedouble
Size[1 1] scalar

MATLAB System Block Limitations

These capabilities are currently not supported.

CategoryLimitation DescriptionWorkaround

System Objects

Tunable logical and character vector properties of the System object are nontunable parameters in the MATLAB System block.

Data Types

  • The MATLAB System block does not support virtual buses as input or output.

  • System objects cannot use fixed-point signals with nonbinary point scaling or nonzero bias.

  • System objects cannot use user-defined opaque data types.

Sample Time

Cannot use MATLAB System blocks to model continuous time or multirate systems.


Cannot use Jacobian based linearization.

Global Variables

Global variables defined in the model Configuration Parameters Simulation Target > Custom Code pane and referenced by the System object are not shared with Stateflow® and the MATLAB Function block.

Turn on the Import custom code option in the Simulation Target pane of the Configuration Parameters dialog box.


MATLAB debugging for code-generation-based simulation.

Set the MATLAB System block Simulate using parameter to Interpreted execution, and then debug. When you are done, set Simulate using back to Code generation.

Fixed-Point Tool

The Fixed-Point Tool does not return design min/max, min/max logging, and autoscaling information for MATLAB System blocks.

Model coverage analysis (Simulink Coverage™ software)

Simulink Coverage cannot perform model analysis for MATLAB System block with Simulate using parameter set to Interpreted execution.

Check model compatibility (Simulink Design Verifier™ software)

Simulink Design Verifier cannot perform compatibility checks for a model or subsystem that contains a MATLAB System block.

MATLAB System and System Objects Examples

For examples of MATLAB System and System objects, see:


System Identification for an FIR System Using MATLAB System Blocks

This example shows how to use the MATLAB System block to implement Simulink blocks using a System object. It highlights two MATLAB System blocks. Access the MATLAB source code for each System object by clicking the Source code link from the block dialog box.

Variable-Size Input and Output Signals Using MATLAB System Blocks

This example shows how to use the MATLAB System block to implement Simulink blocks with variable-size input and output signals. Due to the use of variable-size signals, the example uses propagation methods.

Illustration of Law of Large Numbers Using MATLAB System Blocks

This example shows how to use MATLAB System blocks to illustrate the law of large numbers. Due to the use of MATLAB functions not supported for code generation, the example uses propagation methods and interpreted execution.

Using Buses with MATLAB System Blocks

This example shows how to use MATLAB System blocks with nonvirtual buses at input or output. Due to the use Simulink buses, the example uses propagation methods. The example defines the bus types in the MATLAB base workspace using model callbacks.

See Also

Related Examples

More About