Use MATLAB® code to get and set the properties of annotations.
Simulink.Annotation
class
Set the properties of annotations.
getCallbackAnnotation
function
Get the Simulink.Annotation
object for the annotation
associated with the currently executing annotation callback function. Use this
function to determine which annotation invoked the current callback. This function is
also useful if you write a callback function in a separate MATLAB file that contains multiple callback calls.
You can use a Simulink.Annotation
object to create an
annotation. For example:
open_system('vdp') note = Simulink.Annotation('vdp/This is an annotation'); note.position = [10,50]
To create an area, use the add_block
function. You can position the
area in the model using the Position
parameter.
add_block('built-in/Area','vdp/This is an Area','Position',[120,100,230,200])
To delete an annotation programmatically, use the find_system
function to get the annotation handle. Then use the
delete
function to delete the annotation. For example:
delete(find_system(gcs,'FindAll','on','type','annotation',... 'text','programmatically created'));
Use command such as this to find all of the annotations in a model.
open_system('vdp') annotations = find_system(gcs,'FindAll','on','Type','annotation')
annotations = 34.0004 33.0009
See the find_system
documentation
for specifying levels of the model to search.
To identify the annotation handle of annotations, enter:
get_param(annotations,'Name')
ans = 'Copyright 2004-2014 The MathWorks, Inc.' 'van der Pol Equation'
When you create an annotation, by default it appears in the model. You can configure an annotation to be a markup annotation, which you can hide.
To find out whether the first annotation is a markup annotation, use commands such as this:
open_system('vdp') annotations = find_system(gcs,'FindAll','on','Type','annotation') get_param(annotations(1),'MarkupType')
To configure the first annotation in a model so that it can be hidden, use a commands such as this:
set_param(annotations(1),'MarkupType','markup')
To reconfigure that annotation to always appear, use this command:
set_param(annotations(1),'MarkupType','model')
To find out whether a model is configured to show or hide markup
annotations, use a command such as this for the vdp
model:
get_param(vdp,'ShowMarkup')
To configure a model to hide markup annotations, use a command
such as this for the vdp
model:
set_param(vdp,'ShowMarkup','off')