Simulink.ModelWorkspace - Describe model workspace

Description

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.

Property Summary

Name

Access

Description

DataSource

RW

Specifies the source used to initialize this workspace. Valid values are

  • 'MDL-File'

  • 'MAT-File'

  • 'M-Code'

FileName

RW

Specifies the name of the MAT-file used to initialize this workspace. Simulink software ignores this property if DataSource is not 'MAT-File'.

MCode

RW

A string specifying M code used to initialize this workspace. Simulink software ignores this property if DataSource is not 'M-Code'.

Method Summary

Name

Description

assignin

Assign a value to a variable in the model's workspace.

clear

Clear the model's workspace.

evalin

Evaluate an expression in the model's workspace.

reload

Reload the model workspace from the workspace's data source.

save

Save the model's workspace to a specified MAT-file.

saveToSource

Save the workspace to the MAT-file that the workspace designates as its data source.

whos

List the variables in the model workspace.

Methods

assignin

Purpose

Assign a value to a variable in the model's workspace.

Syntax

assignin('varname', varvalue)

Arguments

varname

Name of the variable to be assigned a value.

varvalue

Value to be assigned the variable.

Description

This method assigns the value specified by varvalue to the variable whose name is varname.

See also

evalin

clear

Purpose

Clear the model's workspace.

Syntax

clear

Description

This method empties the workspace of its variables.

evalin

Purpose

Evaluate an expression in the model's workspace.

Syntax

evalin('expression')

Arguments

expression

A MATLAB expression to be evaluated.

Description

This method evaluates expression in the model workspace.

See also

assignin

reload

Purpose

Reload the model workspace from the workspace's data source.

Syntax

reload

Description

This method reloads the model workspace from the data source specified by its DataSource parameter.

See also

saveToSource

save

Purpose

Save the model's workspace to a specified MAT-file.

Syntax

save('filename')

Arguments

filename

Name of a MAT-file.

Description

This method saves the model's workspace to the MAT-file specified by filename.

Example

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

See also

reload, saveToSource

saveToSource

Purpose

Save the workspace to the MAT-file that it designates as its data source.

Syntax

saveToSource

Description

This method saves the model workspace designated by its FileName property.

Example

hws = get_param('mymodel','modelworkspace')  
hws.DataSource = 'MAT-File';  
hws.FileName = 'params';  
hws.assignin('roll', 30);  
hws.saveToSource;

See also

save, reload

whos

Purpose

List the variables in the model workspace.

Syntax

whos

Description

This method lists the variables in the model's workspace. The listing includes the size and class of the variables.

Example

>> hws = get_param('mymodel','modelworkspace'); 
>> hws.assignin('k', 2);
>> hws.whos

  Name      Size                    Bytes  Class

  k         1x1                         8  double array
  


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