Main Content

Simulink.SFunctionBuilder.setSettings

Set settings for S-Function Builder block

    Description

    Simulink.SFunctionBuilder.setSettings(blk,Name=Value) sets the settings specified using one or more name-value arguments for the S-Function Builder block blk. Use the Simulink.SFunctionBuilder.setSettings function to configure:

    • The array layout for your code

    • The sample mode for the S-function

    • The sample time for the S-function

    • The number of pointers used in the S-function code

    • Whether to make the SimStruct available to the S-Function Builder wrapper functions

    • Support for direct feedthrough.

    To configure the build options for the S-Function Builder block, use the Simulink.SFunctionBuilder.setBuildOptions function.

    To specify a name for the S-function, use the Simulink.SFunctionBuilder.setSFunctionName function.

    To specify the language for the S-function, use the Simulink.SFunctionBuilder.setTargetLanguage function.

    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.

    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:

    Array layout for code, specified as 'Column' or 'Row'.

    Example: ArrayLayout="Row"

    Data Types: char | string

    Sample mode for S-function, specified as 'Inherited', 'Continuous', or 'Discrete'. The sample mode for the block determines when the block computes a new output value.

    • 'Inherited' — The S-Function Builder block inherits sample time from the block connected to the input port.

    • 'Continuous' — The S-Function Builder block computes a new output value for every simulation time step.

    • 'Discrete' — The S-Function Builder block computes a new output value at a fixed sample time you specify.

    Example: SampleMode="Continuous"

    Data Types: char | string

    Discrete sample time for S-function, specified as a scalar, a string, or a character vector. By default, the sample time for an S-Function Builder block is 'Inherited' because the default sample mode is 'Inherited'.

    Specify the SampleTime name-value argument only when the SampleMode is set to Discrete.

    Example: SampleMode="Discrete",SampleTime=0.2

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | char | string

    Number of pointers used in S-function, specified as a scalar, a string, or a character vector.

    S-functions that use PWorks do not support model operating points.

    Example: NumberOfPWorks=3

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | char | string

    Option to enable access to SimStruct in wrapper functions, specified as logical 0 (false) or 1 (true). When you enable access to the SimStruct, you can use SimStruct macros and functions in the code you write for the Outputs_wrapper, Derivatives_wrapper, and Update_wrapper functions.

    Example: UseSimStruct=true

    Data Types: logical

    Whether S-function has direct feedthrough, specified as logical 1 (true) or 0 (false).

    The direct feedthrough flag for the S-function affects block execution order and is used to detect algebraic loops.

    For more information, see S-Function Concepts.

    Example: DirectFeedthrough=false

    Data Types: logical

    Version History

    Introduced in R2022a