how to clear all the variables in the GUI every time when we run it?

3 Ansichten (letzte 30 Tage)
Manoj Kumar
Manoj Kumar am 3 Feb. 2015
Kommentiert: Image Analyst am 3 Feb. 2015
Hi,
I have a GUI in which I'll load an image and do some analysis to it. But, when I load the next image to do analysis in the same GUI, I want to clear all the variables.
I used "clear all" in the callback of push button where I'll load the image.
But, I am facing error as
Reference to a cleared variable handles.
Error in Immunostaining_GUI>load_image_Callback (line 110)
set(handles.text1,'string',details);
Any suggestions please.
Thanks...

Antworten (1)

Image Analyst
Image Analyst am 3 Feb. 2015
You don't want to do that! Doing that will blow away the handles structure which is essential for running your GUIDE-built GUI. When you click some button, say Go!, to start off your image processing, it will run the callback for the Go! button and when it enters that callback, there will be no variables existing except the handles structure. So there is nothing to clear - no need to. You have to create all variables that you will need and use, for example by using global, getappdata, the handles fields, reading mat files, reading workbooks, reading image files with imread(), calling zeros() or ones() or rand(), etc., or by simple assignment
  2 Kommentare
Manoj Kumar
Manoj Kumar am 3 Feb. 2015
Actually I am not closing and opening the GUI to load another image. Without closing it i need to load another image. The reason to clear the past variables is because some variables are not needed when I load another image.
Image Analyst
Image Analyst am 3 Feb. 2015
I know you're not, but you're still entering a callback function to do your operations. And that callback function has a completely new workspace - clean slate with no variables in it except handles. Why do you think the variables are still in existence???

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by