MATLAB Answers


UserData goes empty when I use restore link

Asked by Adrian Dronca on 5 Feb 2013

Hello all,

I've created a toolbox and saved all the data in UserData. I've made the toolbox a library and after I copy the library into a normal model I disable the link.

The UserData data is still present, but when I restore the link to the library the UserData = [];

Why is this happening ? I need to restore the link in the models when I make small updates to the library.

Best Regards, Adrian


You are talking about Simulink, correctly? UserData are usually volatile, such that a reloading of the object must initialize it before using.

Yes, I am talking about Simulink. I set the parameter UserDataPersistent to on.

Log in to comment.


1 Answer

Answer by Jan Simon
on 5 Feb 2013
Edited by Jan Simon
on 5 Feb 2013
 Accepted Answer

Does the note on associating-user-data-with-blocks solve your problem?

Setting UserDataPersitent does:

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

Does this mean, that you have to save the block to store the user data also? If so, did you save the block after setting the UserData?


So I have a library containing a block with UserData. In other models where I use the block there will be no update on the UserData when I change the library's block UserData even if it's linked because the saved data is associated with the library model ?

Have I understood correctly ? Do you by any chance know of another way of saving the data embedded in the block ?

I do not understand the 2nd sentence. Splitting this sentence into smaller parts might support my understanding as a non-native speaker.

However, I'm convinced that the bahaviour of the UserData is explained exactly and exhaustively in the documentation of Simulink.

It's OK, I can work with this also.

Thank you for your support.

Log in to comment.

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today