Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Access to my parameters of a Simulink model list from Matlab command line

36 views
Skip to first unread message

Alex

unread,
Aug 21, 2009, 10:46:02 AM8/21/09
to
Hi,

in the user guide for simulink a read something about

Using Model Workspaces

Using MATLAB Commands to Change Workspace Data

To use MATLAB commands to change data in a model workspace, first get the workspace for the currently selected model:

hws = get_param(bdroot, 'modelworkspace');

This command returns a handle to a Simulink.ModelWorkspace object whose properties specify the source of the data used to initialize the model workspace. Edit the properties to change the data source. Use the workspace's methods to list, set, and clear variables, evaluate expressions in, and save and reload the workspace.

For example, the following MATLAB sequence of commands creates variables specifying model parameters in the model's workspace, saves the parameters, modifies one of them, and then reloads the workspace to restore it to its previous state.

hws = get_param(bdroot, 'modelworkspace');
hws.DataSource = 'MAT-File';
hws.FileName = 'params';
hws.assignin('pitch', -10);
hws.assignin('roll', 30);
hws.assignin('yaw', -2);
hws.saveToSource;
hws.assignin('roll', 35);
hws.reload;

Is there a possibility to load all my parameteres in my workspace in change then their values? I would like to change their declaration ( what variablename they get) and their values through matlab commands.

***

0 new messages