Delete previous xline on app.UIAxes

How to delete previous xline on app.UIAxes? Let say if I want to change a new value, the previous lines are still on the app.UIAxes. I have tried
xline(app.UIAxes,rotorbar_LSB,'Color','green','LineStyle','--','LineWidth',1.5,'DisplayName','Broken Rotor Bar LSB');
hold (app.UIAxes,'off')
delete (xline(app.UIAxes,rotorbar_LSB,'Color','green','LineStyle','--','LineWidth',1.5,'DisplayName','Broken Rotor Bar LSB'))
but seems like it does not work. The previous xline is still there.

Réponses (1)

Voss
Voss le 14 Avr 2022
Store the line when it is created:
app.xline_handle = xline(...);
Later, delete the line:
delete(app.xline_handle);
app.xline_handle = [];

3 commentaires

I have tried but the app.UIAxes appears blank. I have defined the xline_handle as property.
Voss
Voss le 14 Avr 2022
Can you share the complete code?
% plot sideband frequencies for broken rotor bar
app.xline_brbLSB=xline(app.UIAxes,rotorbar_LSB,'Color','green','LineStyle','--','LineWidth',1.5,'DisplayName','Broken Rotor Bar LSB');
delete (app.xline_brbLSB);
app.xline_brbLSB=[];

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Produits

Version

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by