Skip to Main Content Skip to Search
Product Documentation

intersect - Returns intersection of two vectors of Simulink.WorkspaceVar objects

Syntax

VarsOut = intersect (VarsIn1, VarsIn2)
VarsOut = VarsIn1.intersect (VarsIn2)

Description

VarsOut = intersect (VarsIn1, VarsIn2) inputs two vectors of Simulink.WorkspaceVar objects and returns a vector containing a Simulink.WorkspaceVar 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.WorkspaceVar.intersect) and gives identical results.

Input Arguments

VarsIn1

A vector of Simulink.WorkspaceVar objects

VarsIn2

Another vector of Simulink.WorkspaceVar objects

Output Arguments

VarsOut

A vector of Simulink.WorkspaceVar 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.

Examples

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);

See Also

intersect | setdiff | Simulink.findVars | Simulink.WorkspaceVar

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS