Main Content

delete

Delete annotation

Syntax

Description

delete(a) deletes the specified annotation.

example

Examples

collapse all

This example shows how to delete an annotation in the vdp model programmatically.

Open the example. Then, open the vdp model.

open_system('vdp')

At the top of the Van der Pol Equation model is an annotation with the text "Van der Pol Equation". Underneath is a second annotation displaying the equation.

To get the handles for the annotations in the model, use the find_system function.

h = find_system(gcs,'FindAll','on','Type','annotation');

To identify the annotations, query the text inside the annotations.

get_param(h,'PlainText')
ans = 3×1 cell
    {'Copyright 2004-2024 The MathWorks, Inc.'}
    {'Van der Pol Equation'                   }
    {'x_1' =x_2↵↵x_2' =µ(1-x_1^2) x_2 - x_1'  }

To delete the annotation at the top of the model, 'Van der Pol Equation', get the Simulink.Annotation object that corresponds to the second handle.

an = get_param(h(2),'Object');

Delete the annotation from the model.

delete(an)

Van der Pol Equation model without the annotation at the top that says "Van der Pol Equation"

Get the handles for the annotations in the model. Then, query the text inside the annotations.

h1 = find_system(gcs,'FindAll','on','Type','annotation');
get_param(h1,'PlainText')
ans = 2×1 cell
    {'Copyright 2004-2024 The MathWorks, Inc.'}
    {'x_1' =x_2↵↵x_2' =µ(1-x_1^2) x_2 - x_1'  }

The model no longer has an annotation with 'Van der Pol Equation' as text.

Input Arguments

collapse all

Annotation, specified as a Simulink.Annotation object.

Version History

Introduced before R2006a