| Contents | Index |
VarsOut = intersect (VarsIn1, VarsIn2)
VarsOut = VarsIn1.intersect
(VarsIn2)
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.
VarsIn1 |
A vector of Simulink.WorkspaceVar objects |
VarsIn2 |
Another vector of Simulink.WorkspaceVar objects |
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. |
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);intersect | setdiff | Simulink.findVars | Simulink.WorkspaceVar

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 |