iterate

Iterate over model elements

Description

iterate(architecture,iterType,iterFunction) iterates over components in the architecture in the order specified by iterType and invokes the function specified by the function handle iterFunction on each component.

iterate(___,Name,Value) iterates over components in the architecture, with additional options specified by one or more name-value pair arguments.

example

iterate(___,additionalArgs) passes all trailing arguments as arguments to iterFunction.

Examples

collapse all

Open the example Battery Sizing and Automotive Electrical System Analysis.

archModel = systemcomposer.openModel('scExampleAutomotiveElectricalSystemAnalysis');
% Instantiate battery sizing class used by analysis function to store
% analysis results.
objcomputeBatterySizing = computeBatterySizing;
% Run the analysis using the iterator
iterate(archModel,'Topdown',@computeLoad,objcomputeBatterySizing);

Input Arguments

collapse all

Architecture to iterate over, specified as an systemcomposer.arch.Architecture object.

Iteration type, specified as 'PreOrder', 'PostOrder', 'TopDown', or 'BottomUp'.

Data Types: char

Iteration function, specified as a function handle to be iterated on each component.

Data Types: string

Additional function arguments, specified as a comma-separated list of arguments to be passed to iterFunction.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: iterate(archModel,'Topdown',@computeLoad,objcomputeBatterySizing)

Option to recursively iterate through model components, specified as the comma-separated pair consisting of 'Recurse' and a numeric or logical 1 (true) to recursively iterate or 0 (false) to iterate over components only in this architecture and not navigate into the architectures of child components.

Data Types: logical

Option to iterate over components and architecture ports, specified as the comma-separated pair consisting of 'IncludePorts' and a numeric or logical 0 (false) to only iterate over components or 1 (true) to iterate over components and architecture ports.

Data Types: logical

Option to ensure components are visited according to how they are connected from source to destination, specified as the comma-separated pair consisting of 'FollowConnectivity' and a numeric or logical 0 (false) or 1 (true). If this option is specified as 1 (true), iteration type has to be either 'TopDown' or 'BottomUp'. If any other option is specified, iteration defaults to 'TopDown'.

Data Types: logical

Introduced in R2019a