I got some errors when I closed GUI. How do I fix it?
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I want to clear my error when I close my GUI
I do iteration to axes
while keepGoing
axes(handles.axes1); %#ok<LAXES>
a=imread('g4.jpeg');
imshow(a);
pause(5);
end
I got some errors when I closed my GUI
0 Commenti
Risposte (1)
Cam Salzberger
il 15 Gen 2020
Hey Aaron,
The error is likely because the code is trying to execute after you closed the figure window. Closing the figure destroys the axes, making the call to "axes" throw that error.
There are two simple fixes, and you can technically do both. The first is to add a "CloseRequestFcn" to the figure that changes a property that is checked by the while loop. An easier way is probably just to check that the axes are still valid before trying to use them, and dropping out of the loop if they're not valid:
while keepGoing && isvalid(handles.axes1)
...
end
Also, you can specify the axes to plot to directly in "imshow", using the 'Parent' name-value pair. So no need for the call to "axes". You may also consider updating "keepGoing" within the loop, as it currently doesn't seem like it will (unless it's a function call that checks some property or something). Finally, you can call "imshow" directly with the filename, so no need for a separate call to "imread", unless you use the results later.
-Cam
2 Commenti
Cam Salzberger
il 16 Gen 2020
Remember to use imshow(a, 'Parent', handles.axes1), in case it becomes the non-active axes.
The OutputFcn is different from the OpeningFcn, so I can't be sure. I'd assume that the OpeningFcn is ending because you've closed the GUI, and then it tries to call the OutputFcn after that. It probably tries to get the handles struct using guidata, but that will probably return an empty array (or fail completely) if the figure is invalid.
If you don't need the output function, just remove the contents.
Vedere anche
Categorie
Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!