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(architecture,iterType,iterFunction,'Recurse',false) iterates over components only in this architecture and does not navigate into the architectures of child components.

iterate(architecture,iterType,iterFunction,'IncludePorts',true) iterates over components and architecture ports.

iterate(architecture,iterType,iterFunction,'FollowConnectivity',true) ensures components are visited according to how they are connected from source to destination. If this option is specified, iteration type has to be either 'TopDown' or 'BottomUp'. If any other option is specified, iteration defaults to 'TopDown'.

iterate(architecture,iterType,iterFunction,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 stores
% analysis results.
objcomputeBatterySizing = computeBatterySizing;
% Run the analysis using the iterator
archModel.iterate('Topdown',@computeLoad,objcomputeBatterySizing);

Input Arguments

collapse all

The iteration type traverses elements in 'depth-first pre-order', 'depth-first post-order', 'breadth-first top-down', or 'breadth-first bottom-up' order.

Data Types: systemcomposer.arch.Architecture

The iteration type traverses elements in 'depth-first pre-order', 'depth-first post-order', 'breadth-first top-down', or 'breadth-first bottom-up' order.

Data Types: char

Handle to the function to be iterated on each component.

Data Types: string

Comma separated list of arguments to be passed to iterFunction

See Also

Introduced in R2019a