Why does the 'UserData' property for a block not persist across Simulink sessions even though I have the 'UserDataPersistent' property set to 'on'?
2 views (last 30 days)
Show older comments
MathWorks Support Team
on 27 Jul 2015
Edited: MathWorks Support Team
on 4 Mar 2021
Why does the 'UserData' property for a block not persist across Simulink sessions even though I have the 'UserDataPersistent' property set to 'on'?
Accepted Answer
MathWorks Support Team
on 4 Mar 2021
Edited: MathWorks Support Team
on 4 Mar 2021
Any entity that can be saved in a MAT file and then loaded back to the MATLAB workspace will persist when saved in the 'UserData' field for a block.
For example, a .NET object cannot be saved in a MAT file and retrieved later. Hence, if it is attached to the 'UserData' property, it will be lost if the model is closed or Simulink is closed. This is documented in the limitations below:
The 'UserData' and 'UserDataPersistent' properties for any block can be set using the 'set_param' command. For example, after selecting a block in a Simulink block diagram, the following commands can be used to set the properties:
>> set_param(gcb,'UserData',5)
>> set_param(gcb,'UserDataPersistent','on')
0 Comments
More Answers (0)
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!