how delete xline in app designer

3 views (last 30 days)
Luca Re
Luca Re on 5 Oct 2023
Commented: Luca Re on 9 Oct 2023
function RilevaPeriodoButtonValueChanged(app, event)
value = app.RilevaPeriodoButton.Value;
if value
A=app.Eq.Live.idxBackTestInizio;
B=app.Eq.Live.idxBackTestFine;
TRIL=app.Eq.RP_bin(A:B);
% disp(find(TRIL))
xline(app.UIAxes_Eq_2,find(TRIL),'HandleVisibility','off')
else
%%DELETE IT! HOW??
end

Answers (1)

Jinal
Jinal on 9 Oct 2023
Edited: Jinal on 9 Oct 2023
Hello Luca,
As per my understanding, you would like to know how to delete a ‘ConstantLine’ created using ‘xline’ function in App Designer.
The ‘delete’ function can be used to delete a graphic object such as a ‘ConstantLine’.
Refer to the following sample code for creating and deleting a constant vertical line by changing the state of a ‘StateButton’ in App Designer:
properties (Access = private)
x1 = [];
end
% Callbacks that handle component events
methods (Access = private)
% Value changed function: Button
function ButtonValueChanged(app, event)
value = app.Button.Value
if value
app.x1 = xline(app.UIAxes,0.2,'HandleVisibility','off');
else
if(isprop(app,'x1'))
delete(app.x1);
end
end
end
end
Please refer to the following documentation to know about deleting graphic objects using the ‘delete’ function:
I hope this resolves the issue you were facing.
  1 Comment
Luca Re
Luca Re on 9 Oct 2023
hi, I already tried that solution but it doesn't work..
disp(isprop(app,'x1'))
if(isprop(app,'x1'))
delete(app.x1);
end
end
>> 0

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!