Main Content

union

Return union of two arrays of Simulink.VariableUsage objects

Description

VarsOut = union(VarsIn1,VarsIn2) returns an array that is a combined set of the variables from VarsIn1 and VarsIn2, which are arrays of Simulink.VariableUsage objects. The output array does not contain duplicates. If a variable is described by a Simulink.VariableUsage object in VarsIn1 and in VarsIn2, the function returns a Simulink.VariableUsage object that stores the variable usage information from both objects in the Users property.

To create Simulink.VariableUsage objects that describe the usage of variables in a model, use the Simulink.findVars function.

example

Examples

collapse all

Given two models, discover the combined set of variables from both models.

model1Vars = Simulink.findVars('model1');
model2Vars = Simulink.findVars('model2');
unionVars = union(model1Vars,model2Vars);

Input Arguments

collapse all

First array of variables for union, specified as an array of Simulink.VariableUsage objects.

Second array of variables for union, specified as an array of Simulink.VariableUsage objects.

Output Arguments

collapse all

Combined set of variables that are described in input arrays, returned as an array of Simulink.VariableUsage objects. The function returns an object for each variable that is described in VarsIn1 or in VarsIn2.

Version History

Introduced in R2019b