intersect - Return intersection of two arrays of Simulink.VariableUsage
objects - MATLAB ([original](https://in.mathworks.com/help/simulink/slref/simulink.variableusage.intersect.html)) ([raw](?raw))
Main Content
Return intersection of two arrays of Simulink.VariableUsage
objects
Syntax
Description
[VarsOut](#d126e801271) = intersect([VarsIn1](#d126e801221),[VarsIn2](#d126e801244))
returns an array that identifies the variables described inVarsIn1
and in VarsIn2
, which are arrays of Simulink.VariableUsage objects. If a variable is described by a Simulink.VariableUsage
object inVarsIn1
and in VarsIn2
, the function returns a Simulink.VariableUsage
object that stores the variable usage information from both objects in the Users
property.
intersect
compares the Name
,Source
, and SourceType
properties of theSimulink.VariableUsage
objects in VarsIn1
with the same properties of the objects in VarsIn2
. IfVarsIn1
and VarsIn2
each containSimulink.VariableUsage
objects that have the same values for these three properties, they both describe the same variable.
To create Simulink.VariableUsage
objects that describe the usage of variables in a model, use the Simulink.findVars function.
Examples
Given two models, discover the variables needed by both models.
model1Vars = Simulink.findVars('model1'); model2Vars = Simulink.findVars('model2'); commonVars = intersect(model1Vars,model2Vars);
Input Arguments
First array of variables for comparison, specified as an array ofSimulink.VariableUsage
objects.
Second array of variables for comparison, specified as an array ofSimulink.VariableUsage
objects.
Output Arguments
Variables that are described in both input arrays, returned as an array ofSimulink.VariableUsage
objects. The function returns an object for each variable that is described in VarsIn1
and in VarsIn2
.
Version History
Introduced in R2012b