This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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

    Note   If persistent UserData for a block contains any Simulink data objects, the directories containing the definitions for the classes of those objects must be on the MATLAB path when you open the model containing the block.

Related Topics

Was this topic helpful?