While Iterator Subsystem - Repeat subsystem execution during simulation time step while logical expression

        is true - Simulink ([original](https://www.mathworks.com/help/simulink/slref/whileiteratorsubsystem.html)) ([raw](?raw))

Repeat subsystem execution during simulation time step while logical expression is true

Libraries:
Simulink / Ports & Subsystems

Description

The While Iterator Subsystem block is a Subsystem block preconfigured as a starting point for creating a subsystem that repeats execution during a simulation time step while a logical condition istrue. Execution is controlled by a While Iterator block inside the subsystem. For an example, see ex_while_iterator_block.

Note

To break a loop and terminate the simulation manually before the simulation stop time of a model, press Ctrl + C.

Use While Iterator Subsystem blocks to model:

When using simplified initialization mode, if you place a block that needs elapsed time (such as a Discrete-Time Integrator block) in a While Iterator Subsystem block, Simulink® displays an error.

If the output signal from a While Iterator Subsystem block is a function-call signal, Simulink displays an error when you simulate the model or update the diagram.

Examples

Ports

Input

expand all

Placing an Inport block in a subsystem block adds an external input port to the block. The port label matches the name of theInport block.

Use Inport blocks to get signals from the local environment.

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

Placing a While Iterator block connected to anInput block in a Subsystem block adds this external input port to the block.

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

Output

expand all

Placing an Outport block in a subsystem block adds an output port from the block. The port label on the subsystem block is the name of the Outport block.

Use Outport blocks to send signals to the local environment.

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

Parameters

expand all

To edit block parameters interactively, use theProperty Inspector. From the Simulink Toolstrip, on the Simulation tab, in thePrepare gallery, select Property Inspector.

Main

Select how to display port labels on the Subsystem block icon.

For port label editing on Subsystem blocks, see Edit Port Labels on Subsystem Blocks.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: ShowPortLabels
Values: 'FromPortIcon' (default) | 'FromPortBlockName' 'SignalName' 'none'

Control user access to the contents of the subsystem.

You do not receive a response if you attempt to view the contents of a subsystem whose Read/Write permissions parameter is set to NoReadOrWrite. For example, when double-clicking such a subsystem, the software does not open the subsystem and does not display any messages.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: Permissions
Values: 'ReadWrite' (default) | 'ReadOnly' 'NoReadOrWrite'

Enter the name of a function to be called if an error occurs while the software executes the subsystem.

The software passes two arguments to the function: the handle of the subsystem and a character vector that specifies the error type. If no function is specified, the software displays a generic error message if executing the subsystem causes an error.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: ErrorFcn
Values: '' (default) | function name in quotes
Data Types: char | string

Select whether to resolve names of workspace variables referenced by this subsystem.

For more information, see Symbol Resolution and Symbol Resolution Process.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: PermitHierarchicalResolution
Values: 'All' (default) | 'ExplicitOnly' 'None'

Select this parameter to display the reinitialize event ports. Clear this parameter to remove the ports.

Dependencies

To enable this parameter, select Treat as atomic unit.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: ShowSubsystemReinitializePorts
Values: 'off' (default) | 'on'

Code Generation

Parameters on the Code Generation tab require a Simulink Coder™ or Embedded Coder® license.

Select the code format to be generated for an atomic (nonvirtual) subsystem.

For more information, see:

The default value depends on the block configuration. For example, the default value for the Subsystem block is Auto. The default value for the CodeReuseSubsystem block isReusable function.

Tips

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWSystemCode
Values: 'Auto' | 'Inline' 'Nonreusable function' 'Reusable function'

Select how the software names the function it generates for the subsystem.

If you have an Embedded Coder license, you can control function names with options on the Configuration Parameter > pane.

For more information, see Generate Subsystem Code as Separate Function and Files (Simulink Coder).

The default value depends on the block configuration. For example, the default value for the Subsystem block is Auto. The default value for the CodeReuseSubsystem block isUse subsystem name.

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWFcnNameOpts
Values: 'Auto' | 'Use subsystem name' 'User specified'

Specify a unique, valid C or C++ function name for subsystem code.

Use this parameter if you want to give the function a specific name instead of allowing the Simulink Coder code generator to assign its own autogenerated name or use the subsystem name. For more information, see Generate Subsystem Code as Separate Function and Files (Simulink Coder).

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWFcnName
Values: '' (default) | function name in quotes
Data Types: char | string

Select how the software names the separate file for the function it generates for the subsystem.

The default value depends on the block configuration. For example, the default value for the Subsystem block is Auto. The default value for the CodeReuseSubsystem block isUse function name.

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWFileNameOpts
Values: 'Auto' | 'Use subsystem name' 'Use function name' 'User specified'

The filename that you specify does not have to be unique. However, avoid giving non-unique names that result in cyclic dependencies. For example,sys_a.h includes sys_b.h,sys_b.h includes sys_c.h, andsys_c.h includes sys_a.h.

For more information, see Generate Subsystem Code as Separate Function and Files (Simulink Coder).

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWFileName
Values: '' (default) | filename in quotes
Data Types: char | string

Select how to use arguments with the generated function.

In some cases, when generating optimized code, the code generator might not generate a function that has arguments.

For more information, see:

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: FunctionInterfaceSpec
Values: 'void_void' (default) | 'Allow arguments (Optimized)' 'Allow arguments (Match graphical interface)'

Generate subsystem function code in which the internal data for an atomic subsystem is separated from its parent model and is owned by the subsystem.

For details on how to generate modular function code for an atomic subsystem, seeGenerate Modular Function Code for Nonvirtual Subsystems (Embedded Coder).

For details on how to apply memory sections to atomic subsystems, see Override Default Memory Placement for Subsystem Functions and Data (Embedded Coder).

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: FunctionWithSeparateData
Values: 'off' (default) | 'on'

Select how the software applies memory sections to the subsystem initialization and termination functions.

Tips

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWMemSecFuncInitTerm
Values: 'Inherit from model' (default) | 'Default' model memory section in quotes

Select how Embedded Coder applies memory sections to the subsystem execution functions.

Tips

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWMemSecFuncExecute
Values: 'Inherit from model' (default) | 'Default' model memory section in quotes

Select how the software applies memory sections to the subsystem constants.

Tips

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWMemSecDataConstants
Values: 'Inherit from model' (default) | 'Default' model memory section in quotes

Select how the software applies memory sections to the subsystem internal data.

Tips

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWMemSecDataInternal
Values: 'Inherit from model' (default) | 'Default' model memory section in quotes

Select how the software applies memory sections to the subsystem parameters.

Tips

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWMemSecDataParameters
Values: 'Inherit from model' (default) | 'Default' model memory section in quotes

Block Characteristics

Data Types Booleana | busa doublea enumerateda fixed pointa halfa integera singlea stringa
Direct Feedthrough no
Multidimensional Signals yesa
Variable-Size Signals yesa
Zero-Crossing Detection no
a Actual data type or capability support depends on block implementation.

Extended Capabilities

expand all

Actual code generation support depends on block implementation.

Actual data type support depends on block implementation.

Version History

Introduced before R2006a

expand all

You can now pause a simulation on a particular iteration of an iterator subsystem by adding signal breakpoints to signals produced by:

In previous releases, you could add a breakpoint in these locations, but the breakpoints did not pause the simulation and appeared as invalid in the block diagram.

Port value labels at the same locations now display the iteration number. In previous releases, port value labels at these locations showed inaccessible.

For an example, see Debug Simulation of Iterator Subsystem.