MATLAB: GUI

guiMATLAB

I had created a simple GUI counting the number of cllicks and displaying it in an Edit Box. I noticed two problems :-
1. the gui doesn't work if we directly run the .fig file.. we have to run its .m file first. Any comments?
2. on closing some of my gui's, it generates these type of errors –
*??? Error using ==> feval Undefined function or method 'figure1_DeleteFcn' for input arguments of type 'struct'.
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> loadimg [dats my file name] at 43 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)loadimg('figure1_DeleteFcn',hObject,eventdata,guidata(hObject))
??? Error using ==> delete Error while evaluating figure DeleteFcn*
dont understand what this delete function is matlab talking about.. i just used a push button callback for counting and displaying the number of clicks.. no other function..

Best Answer

1. Correct. You must run the .m file. .fig files are not designed to be executable.
2. You renamed your .m file and .fig file outside of GUIDE. When you do that, GUIDE gets messed up. If you want a different name, you have to do it within GUIDE. Now you will need to check all the code in the .m file to look for references to figure1 and you will need to use the property inspector to go through all the object properties in your .fig file looking for references to figure1 . You will probably find it easier to delete your existing .m and .fig file and to rebuild it in GUIDE.