Engee documentation

For Iterator

Control unit for the for-iterator subsystem.

for iterator subsystem

Description

The For Iterator block, placed in the Subsystem block, repeats the execution of the subsystem during the current time step until the iteration variable exceeds the specified iteration limit. You can use this block to implement a flowchart equivalent to for a loop in a programming language.

The output of the For Iterator Subsystem block cannot be a function call signal. Engee displays an error message when the model is updated.

Ports

Input

N - external value of iteration limit
scalar

Input port to connect to an external iteration limit source. The value on the port is used as the maximum number of iterations of the loop. The input port accepts data of mixed numeric types.

Dependencies

To use this port, set the Iteration limit source parameter to external.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool.

Next_i - external value of the iterator variable
scalar

Input port to connect to an external source of iteration variables. The value of the input at the current iteration is used as the value of the iteration variable at the next iteration. The input port accepts data of mixed numeric types.

Dependencies

To use this port, select the Set Next i (iteration variable) externally checkbox.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool.

Output

1:N - value of the iterator variable during the step
scalar

Value of the iterator variable during the step.

Dependencies

To use this port, select the Show iteration variable checkbox.

Data types: Int8, Int16, Int32, Float64.

Parameters

Iteration limit source - source for number of iterations
internal (by default) | external

Select the source for the number of iterations.

internal - the value of the Iteration limit parameter determines the number of iterations.

external - the value of the signal on the N port determines the number of iterations.

Dependencies

Selecting internal displays and enables the Iteration limit parameter. Selecting external adds an input port labelled N.

Usage in program code

Block parameter

IterationSource

Values

internal | external

By default

internal

Iteration limit - specify the number of iterations
5 (by default) | an integer

Specify the number of iterations. This parameter supports storage classes.

5 - repeat blocks in the For Iterator Subsystem block 5 times.

` integer` - specify an integer or a named constant variable.

Dependencies

To use this parameter, select internal for the Iteration limit source parameter.

Usage in program code

Block parameter

IterationLimit

Values

5 | <integer>

By default

5

Set Next i (iteration variable) externally - control input port mapping
off (by default) | on

Control the input port display.

disabled - do not display the input port.

on - display the input port with the inscription Next_i to connect to an external source of iteration variables. The value of the input at the current iteration is used as the value of the iteration variable at the next iteration.

Dependencies

To use this parameter, select the checkbox for Show iteration variable, which also displays an output port labelled 1:N.

Usage in program code

Block parameter

ExternalIncrement

Values

off | on

By default

off

Show iteration variable - output port display control
On (By default) | Off

Control the output port display.

disabled - do not display the output port.

enabled - display the output port with 1:N.

Dependencies

To use this parameter, tick the checkbox for Set next i (iteration variable) externally.

Usage in program code

Block parameter

ShowIterationPort

Values

on | off

By default

enabled

Index mode - specify the initial iteration number
One-based (by default) | Zero-based

Specify the indexing mode as Zero-based or One-based.

For Zero-based indexing, index 0 specifies the first element of the input vector. Index 1 specifies the second element and so on.

For One-based indexing, index 1 specifies the first element of the input vector. Index 2, specifies the second element and so on.

Usage in program code

Block parameter

IndexMode

Values

Zero-based |One-based

By default

One-based

Iteration variable data type - output data type
Int32 (by default) | Int16 | Int8 | Float64

Set the data type to output the iteration value from the iteration number port.

Usage in program code

Block parameter

IterationVariableDataType

Values

Int32 | Int16 | Int8 | Float64

By default

Int32

Additional options

C code generation: Yes