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
Customize block icons with port labels
Access two simulation modes
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
For help on choosing the right block, see Comparison of Custom Block Functionality.
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.
You can use MATLAB System blocks in Simulink models for simulation via interpreted execution or code generation.
With interpreted execution, the model simulates the block using the MATLAB execution engine.
With code generation, the model simulates the block using code generation (requires the use the subset of MATLAB code supported for code generation). For a list of supported functions, see Functions and Objects Supported for C/C++ Code Generation.
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:
|Size||[1 1] scalar|
These capabilities are currently not supported.
Tunable logical and character vector properties of the System object are nontunable parameters in the MATLAB System block.
Cannot use MATLAB System blocks to model continuous time or multirate systems.
Cannot use Jacobian based linearization.
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
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)
Coverage cannot perform model analysis for MATLAB
System block with Simulate
using parameter set to
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.
For examples of MATLAB System and System objects, see:
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.
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.