Returns intersection of two vectors of Simulink.VariableUsage objects
VarsOut = intersect (VarsIn1, VarsIn2)
VarsOut = VarsIn1.intersect (VarsIn2)
VarsOut = intersect (VarsIn1, VarsIn2) inputs two vectors of Simulink.VariableUsage objects and returns a vector containing a Simulink.VariableUsage object for each variable that is represented in both input vectors. The function compares input objects by comparing their Name, Workspace, and WorkspaceType values. If all three value are the same in both objects, the two objects match. Any returned object is a new object having the same field values as the matching input objects, except that its UsedByBlocks field contains the union of the values in the UsedByBlocks fields of the two matching objects.
VarsOut = VarsIn1.intersect (VarsIn2) is the equivalent method syntax (Simulink.VariableUsage.intersect) and gives identical results.
A vector of Simulink.VariableUsage objects
Another vector of Simulink.VariableUsage objects
A vector of Simulink.VariableUsage objects containing a copy of any object in VarsIn1 that matches an object in VarsIn2. Two objects match if their Name, Workspace, and WorkspaceType values are the same. The UsedByBlocks field of each returned object is the union of the values of that field in the matching input objects.
Given two models, discover which variables are needed by the first model, the second model, or both models:
model1Vars = Simulink.findVars('model1'); model2Vars = Simulink.findVars('model2'); commonVars = intersect(model1Vars, model2Vars);