Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Associating User Data with Blocks

You can use the set_param command to associate your own data with a block. For example, the following command associates the value of the variable mydata with the currently selected block.

set_param(gcb, 'UserData', mydata)

The value of mydata can be any MATLAB data type, including arrays, structures, objects, and Simulink data objects.

Use get_param to retrieve the user data associated with a block.

get_param(gcb, 'UserData')

The following command saves the user data associated with a block in the model file of the model containing the block.

set_param(gcb, 'UserDataPersistent', 'on');

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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