Simulink.ModelWorkspace
Interact with the model workspace of a model programmatically
Description
Use a Simulink.ModelWorkspace object to interact with a model
workspace. For example, you can add and remove variables, set the data source of the
workspace, and save changes to the workspace.
Note
For most common data management tasks involving a model workspace, Simulink® data dictionary (Design Data section), or MAT-file, it is recommended
to use the functions provided by the Simulink.data.DataConnection object over the data source-specific
functions. These object functions provide a common command line interface to manage
the data using fewer lines of code. Use the Simulink.data.connect function to create a connection to your data
source, then use the common set of functions provided by the Simulink.data.DataConnection object. For data source-specific tasks,
for example the removal or addition of a reference data dictionary, create a data
source-specific object, then use the functions provided by that object to manage
your data source. For more information, see Manage Design Data for Simulink Models Programmatically.
For more information, see Model Workspaces.
Creation
To create a Simulink.ModelWorkspace, use the get_param function to query the value of the model parameter
ModelWorkspace. For example, to create an object named
mdlWks that represents the model workspace of a model named
myModel.slx:
mdlWks = get_param('myModel','ModelWorkspace')
Properties
Object Functions
getVariable | Return value of variable in the model workspace of a model |
getVariablePart | Get value of variable property in model workspace |
setVariablePart | Set property of variable in model workspace |
hasVariable | Determine whether variable exists in the model workspace of a model |
whos | Return list of variables in the model workspace of a model |
saveToSource | Save model workspace changes to the external data source of the model workspace |
save | Save contents of model workspace to a MAT-file |
reload | Reinitialize variables from the data source of a model workspace |
evalin | Evaluate expression in the model workspace of a model |
clear | Clear variables from the model workspace of a model |
assignin | Assign value to variable in the model workspace |
Examples
Version History
Introduced before R2006a