Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Simulink.WorkspaceVar class

Package: Simulink

Contains information about workspace variables and blocks that use them

Description

A Simulink.WorkspaceVar object describes attributes of a workspace variable and lists the blocks that use the variable. The Simulink.findVars function returns one or more Simulink.WorkspaceVar objects that embody the results of searching for variables.

Tip

Only a Simulink.WorkspaceVar constructor can set any field value in a Simulink.WorkspaceVar object. The fields are otherwise read-only.

Properties

Name

The name of the variable described by the Simulink.WorkspaceVar object

Workspace

The name of the workspace in which the variable resides, for example:

Workspace valueMeaning
'base workspace'The MATLAB® base workspace
'MyModel'The model workspace for the model MyModel.
'MyModel/Mask1'The mask workspace for the masked block Mask1 in the model MyModel.

WorkspaceType

The type of workspace in which the variable resides. The possible values are:

  • 'base'

  • 'model'

  • 'mask'

UsedByBlocks

A cell array of character vectors. Each character vector names a block that uses the variable. Simulink.findVars populates this field.

Construction

var = Simulink.WorkspaceVar (VarName, WkspName), where both arguments are character vectors, returns a Simulink.WorkspaceVar object with Name VarName and Workspace WkspName. The inputs need not exist in the model. Simulink® will provide a WorkspaceType automatically.

vars = Simulink.WorkspaceVar (VarNames, WkspName), where VarNames is a cell array of character vectors, returns a vector of Simulink.WorkspaceVar objects, each with a specified name and Workspace = WkspName.

Methods

[VarsOut] = VarsIn1.setdiff (VarsIn2) — Calls setdiff to return the difference between VarsIn1 and VarsIn2. The arguments and return value are vectors of Simulink.WorkspaceVar objects.

[VarsOut] = VarsIn1.intersect (VarsIn2) — Calls intersect to return the intersection between VarsIn1 and VarsIn2. The arguments and return value are vectors of Simulink.WorkspaceVar objects.

Examples

Create a Simulink.WorkspaceVar object for the variable 'k' in the base workspace.

var = Simulink.WorkspaceVar('k', 'base workspace');

Return a vector of Simulink.WorkspaceVar objects, one object for each variable returned by who.

[vars] = Simulink.WorkspaceVar (who,  WkspName)

Return a vector of Simulink.WorkspaceVar objects, one object for each variable returned by whos.

[vars] = Simulink.WorkspaceVar (who,  WkspName)

Create a vector of Simulink.WorkspaceVar objects that describes all the variables in a model workspace

hws = get_param('mymodel', 'ModelWorkspace');
vars=Simulink.WorkspaceVar(hws.whos, 'MyModel')

Create a vector of Simulink.WorkspaceVar objects that describes all the variables in a mask workspace

maskVars = get_param('mymodel/maskblock', 'MaskWSVariables');
vars = Simulink.WorkspaceVar(maskVars, 'mymodel/maskblock');
Was this topic helpful?