Main Content

Simulink.SFunctionBuilder.add

Add input, output, parameter, library item, or state to S-Function Builder block

Since R2022a

    Description

    Simulink.SFunctionBuilder.add(blk,elem) adds the element elem with default options to the S-Function Builder block blk. Use the Simulink.SFunctionBuilder.add function to add:

    • Input ports

    • Output ports

    • Parameters

    • Library items

    • Discrete states

    • Continuous states

    Simulink.SFunctionBuilder.add(blk,elem,Name=Value) adds the element elem with options specified using one or more name-value arguments to the S-Function Builder block blk. For example, to specify the data type for a port as double, set DataType to double.

    The options you can specify depend on the type of element you add.

    Input Arguments

    collapse all

    S-Function Builder block, specified as a block handle or as a string or a character vector that defines the block path.

    Tips

    • To get the block handle for a block in your model, use the getSimulinkBlockHandle function.

    • To get the block handle for the most recently selected or added block, use the gcbh function.

    Type of element to add, specified as one of these options:

    • 'Input'

    • 'Output'

    • 'Parameter'

    • 'LibraryItem'

    • 'DiscreteState'

    • 'ContinuousState'

    Data Types: char | string

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

    Example: Name="in1",DataType="single" specifies options to configure an input port with the name in1 and data type single.

    Port or parameter name, specified as a string or a character vector. By default:

    • Input ports are named u0, u1, … un.

    • Output ports are named y0, y1, … ,yn.

    • Parameters are named p0, p1, … , pn.

    Specify the Name name-value argument only when you add an input port, an output port, or a parameter.

    Example: Name="inputSignal"

    Data Types: char | string

    Port or parameter data type, specified as one of these options:

    • 'double'

    • 'single'

    • 'boolean'

    • 'int8'

    • 'int16'

    • 'int32'

    • 'uint8'

    • 'uint16'

    • 'uint32'

    • 'Fixdt:binary(a,b,c)'

    • 'Fixdt:slope and bias(a,b,c,d)'

    • 'Bus: <object name>'

    Parameters do not support fixed-point or bus data types.

    Specify the DataType name-value argument only when you add an input port, an output port, or a parameter.

    Example: DataType="single"

    Data Types: char | string

    Port or parameter complexity, specified as 'real' or 'complex'.

    Specify the Complexity name-value argument only when you add an input port, an output port, or a parameter.

    Example: Complexity="complex"

    Data Types: char | string

    Input or output port dimensions, specified as a string or a character vector that defines the port dimensions as a scalar or vector.

    Specify the Dimensions name-value argument only when you add an input or output port.

    Example: Dimensions="2"

    Example: Dimensions="[1,2]"

    Data Types: char | string

    Unit specification for input port, output port, or parameter.

    Example: Unit = 'm/s' assigns the unit of the specified input, output, or parameter as 'm/s'

    Data Types: char | string

    Parameter value, specified as a string or a character vector that defines the value of the parameter.

    Specify the Value name-value argument only when you add a parameter.

    Example: Value="2" specifies the parameter value as 2.

    Example: Value="[1 2]" specifies the parameter value as [1 2].

    Data Types: char | string

    Tag for library item, specified as one of these options:

    • 'SRC_PATH' — Object or library path

    • 'LIB_PATH' — Include search path for header files and source files

    • 'INC_PATH' — Search path for object files and source files

    • 'ENV_PATH' — Environment variable

    • 'ENTRY' — Object, source, or library file name or preprocessor directive, such as -DDEBUG

    When you add a library item to an S-Function Builder block, use the LibraryItemTag and LibraryItemValue name-value arguments together to define the library item.

    Specify the LibraryItemTag name-value argument only when you add a library item.

    Example: LibraryItemTag="LIB_PATH",LibraryItemValue="$MATLABROOT\customobjs"

    Data Types: char | string

    Library item value, specified as a string or a character vector. The value you specify depends on the tag for the library item you add.

    When you add a library item to an S-Function Builder block, use the LibraryItemTag and LibraryItemValue name-value arguments together to define the library item.

    Example: LibraryItemTag="LIB_PATH",LibraryItemValue="$MATLABROOT\customobjs"

    Data Types: char | string

    Initial condition for state, specified as a string or a character vector that defines the initial value for the state.

    Specify the InitialCondition name-value argument only when you add a discrete or continuous state.

    Example: InitialCondition="1" specifies the initial condition for the added state as 1.

    Data Types: char | string

    Version History

    Introduced in R2022a