Clear a line drawn in plot.
이전 댓글 표시
Hello I would like to clear a line that I draw in my graph but I want it to be clean only when I run my function.
When I press button in Matlab GUI I want to draw a line but when I pressed it second time I want to clear that line and draw other. How to simply do this.
채택된 답변
추가 답변 (1개)
Simon
2013년 9월 16일
Hi!
Each time you plot something with the "h=plot" command, it gives you as return value the handle "h" of that plot. Then you may use
delete(h)
You just need to remember this handle (store it somewhere ...)
댓글 수: 4
Jonasz
2013년 9월 16일
Simon
2013년 9월 16일
First time you call your function the handle "h" does not exist. Thus you can write
if exist('h', 'var')
delete(h)
end
The line is deleted only if it exists.
Jonasz
2013년 9월 16일
Simon
2013년 9월 17일
So, in your code above you have everything you need. Storing a variable for future use is done using "guidata". See http://www.mathworks.com/help/matlab/ref/guidata.html?searchHighlight=guidata
카테고리
도움말 센터 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!