MATLAB: Does the Simulink.Annotation object not save correctly or behave strangely in Simulink 7.4 (R2009b)

annotation;getcallbackannotationsimulink

I have Simulink annotation in a model. I can change this annotation object either via the click function callback or manually. When I save the model and reopen it, the annotation reverts back to its original value. Why is this?

Best Answer

This is expected behavior for a Simulink.Annotation object that has a defined LoadFcn in that changes its own Text field in Simulink 7.4 (R2009b).
Load your model and observe the MATLAB base workspace. Alternatively, you can type
whos
to see if you have any Simulink.Annotation objects in your workspace.
If none are present, use the following code to create a handle to any annotation objects;
ah = find_system(gcs, 'FindAll', 'on', 'type', 'annotation');
If you have multiple annotations in your model you may need to reference into the handle such as
get(ah(1))
Observe the LoadFcn of the annotation in question. If this object has a non-null LoadFcn, this will both load the annotation object's handle into the MATLAB workspace when you load the model as well as perform the operation defined in the LoadFcn. In some cases, this may reset the text of the annotation object itself.
The attached example model illustrates this behavior. Load this model and perform the steps above to inspect this issue.