Main Content

Level-2 MATLAB S-Function

Use Level-2 MATLAB S-function in model

  • Level-2 MATLAB S-Function block

Libraries:
Simulink / User-Defined Functions

Description

This block allows you to use a Level-2 MATLAB® S-function (see Write Level-2 MATLAB S-Functions) in a model. To do this, create an instance of this block in the model. Then enter the name of the Level-2 MATLAB S-function in the S-function name field of the block's parameter dialog box.

Note

Use the S-Function block to include a Level-1 MATLAB S-function in a block.

If the Level-2 MATLAB S-function defines any additional parameters, you can enter them in the Parameters field of the block's parameter dialog box. Enter the parameters as MATLAB expressions that evaluate to their values in the order defined by the MATLAB S-function. Use commas to separate each expression.

If a model includes a Level-2 MATLAB S-Function block, and an error occurs in the S-function, the Level-2 MATLAB S-Function block displays MATLAB stack trace information for the error in a dialog box. Click OK to close the dialog box.

Ports

Input

expand all

The Level-2 MATLAB S-Function block accepts inputs of the types listed in the Block Characteristics table. For more information, see Data Types Supported by Simulink. You can configure input port using the setup callback function. Use the setup function to specify number of input ports, dimension of input signals, sample time of each port, and if ports are direct feedthrough.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Output

expand all

Signal output of a Level-2 MATLAB S-Function block that the S-Function returns. You can configure input port using the setup callback function. Use the setup function to specify number of input ports, dimension of input signals and sample time of each port.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus

Parameters

expand all

Specify the name of a MATLAB function that defines the behavior of this block. The MATLAB function must follow the Level-2 standard for writing MATLAB S-functions (see Write Level-2 MATLAB S-Functions for details).

Programmatic Use

Block Parameter: FunctionName
Type: character vector
Values: 'matlabfile' | S-Function name
Default: 'matlabfile'

Specify values of parameters for this block.

Programmatic Use

Block Parameter: Parameters
Type: character vector
Values: values of block parameters
Default: ' '

Block Characteristics

Data Types

Booleana | doublea | fixed pointa | integera | singlea

Direct Feedthrough

yes

Multidimensional Signals

yes

Variable-Size Signals

yes

Zero-Crossing Detection

no

a Level-1 MATLAB S-functions support only the double data type. Level-2 MATLAB S-functions support all data types that Simulink supports.

Extended Capabilities

Version History

Introduced in R2010b