MATLAB Answers

Jakub
0

how do i check if line in plot exists and if yes delete it otherwise nothing

Asked by Jakub
on 6 Nov 2012
Latest activity Answered by Sonima
on 24 Jan 2019
I have GUI with some plots. and in the plot there migt be lines in it. and when i pres certain button i want to check if there are some lines in plot and if so delete them. if there arent any do nothing... Thanks for help!

  0 Comments

Sign in to comment.

2 Answers

Answer by Arthur
on 6 Nov 2012
 Accepted Answer

Dirty way:
cla(axes_handle)
If you know the handle of the line:
if ishandle(line_handle)
delete(line_handle)
end
if you don't know the line handle, use get(axeshandle,'Children') to find it.

  0 Comments

Sign in to comment.


Answer by Sonima
on 24 Jan 2019

Hi!
I want to do the same, delete a line if exist in a plot in a fuction.
I used the suggeste code
if ishandle(line_handle)
delete(line_handle)
end
But I got the error:
Undefined function or variable 'line_handle'.
How can I fix it?!

  0 Comments

Sign in to comment.