how to clear all the variables in the GUI every time when we run it?
2 次查看(过去 30 天)
显示 更早的评论
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...
0 个评论
回答(1 个)
Image Analyst
2015-2-3
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 个评论
Image Analyst
2015-2-3
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???
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!