| Simulink® | ![]() |
Instances of this class describe model workspaces. Simulink software creates an instance of this class for each model that you open during a Simulink session. See Using Model Workspaces in Using Simulink® for more information.
Name | Access | Description |
|---|---|---|
Specifies the source used to initialize this workspace. Valid values are
| ||
Specifies the name of the MAT-file used to initialize this workspace. Simulink software ignores this property if DataSource is not 'MAT-File'. | ||
A string specifying M code used to initialize this workspace. Simulink software ignores this property if DataSource is not 'M-Code'. |
Name | Description |
|---|---|
Assign a value to a variable in the model's workspace. | |
Clear the model's workspace. | |
Evaluate an expression in the model's workspace. | |
Reload the model workspace from the workspace's data source. | |
Save the model's workspace to a specified MAT-file. | |
Save the workspace to the MAT-file that the workspace designates as its data source. | |
List the variables in the model workspace. |
Assign a value to a variable in the model's workspace.
assignin('varname', varvalue)
Name of the variable to be assigned a value.
Value to be assigned the variable.
This method assigns the value specified by varvalue to the variable whose name is varname.
Clear the model's workspace.
clear
This method empties the workspace of its variables.
Evaluate an expression in the model's workspace.
evalin('expression')
A MATLAB expression to be evaluated.
This method evaluates expression in the model workspace.
Reload the model workspace from the workspace's data source.
reload
This method reloads the model workspace from the data source specified by its DataSource parameter.
Save the model's workspace to a specified MAT-file.
save('filename')
Name of a MAT-file.
This method saves the model's workspace to the MAT-file specified by filename.
Note This method allows you to save the workspace to a file other than the file specified by the workspace's FileName property. If you want to save the model workspace to the file specified by the file's FileName property, it is simpler to use the workspace's saveToSource method. |
hws = get_param('mymodel','modelworkspace')
hws.DataSource = 'MAT-File';
hws.FileName = 'workspace';
hws.assignin('roll', 30);
hws.saveToSource;
hws.assignin('roll', 40);
hws.save('workspace_test.mat');
Save the workspace to the MAT-file that it designates as its data source.
saveToSource
This method saves the model workspace designated by its FileName property.
hws = get_param('mymodel','modelworkspace')
hws.DataSource = 'MAT-File';
hws.FileName = 'params';
hws.assignin('roll', 30);
hws.saveToSource;
List the variables in the model workspace.
whos
This method lists the variables in the model's workspace. The listing includes the size and class of the variables.
>> hws = get_param('mymodel','modelworkspace');
>> hws.assignin('k', 2);
>> hws.whos
Name Size Bytes Class
k 1x1 8 double array
![]() | Simulink.ModelDataLogs | Simulink.MSFcnRunTimeBlock | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |