I have a GUI that plots 4 axes in a GUI and I would like to clear those with a button. Tried cla(findall(0,'type','axes')) but it does not do anything. what is wrong with this command?

 Akzeptierte Antwort

Paulo Silva
Paulo Silva am 29 Jun. 2011

6 Stimmen

arrayfun(@cla,findall(0,'type','axes'))

Weitere Antworten (3)

Gerd
Gerd am 29 Jun. 2011

0 Stimmen

Hi Christof,
I think your code should work. Please make sure you are using the right figure handle.
Gerd

3 Kommentare

Paulo Silva
Paulo Silva am 29 Jun. 2011
Please read the documentation, cla just clears the current axes and cla(ax) clears the single axes ax, it doesn't work for multiple axes handles unless you do it like this arrayfun(@cla,findall(0,'type','axes'))
http://www.mathworks.com/help/techdoc/ref/cla.html
Gerd
Gerd am 29 Jun. 2011
cla clears all the children from an axes. And I assume this is what he is talking about, because nothing is happining. You can even use just cla and it should work for one single axes with multiple plots on. If he has the wrong current figure nothing will happen.
Paulo Silva
Paulo Silva am 29 Jun. 2011
Gerd please read the question again, Christof got 4 axes and he wants to clear them all, his code finds all the axes objects but fails because cla just clears the first axes returned by findall.

Melden Sie sich an, um zu kommentieren.

Christof
Christof am 29 Jun. 2011

0 Stimmen

thanks for your help
norfaizayu
norfaizayu am 30 Jan. 2012

0 Stimmen

when i use that source code, the picture in axes clear but the axes still there.how can i clear all that thing?picture in axes and axes all so that's mean will back to normal stage.

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by