Info

This question is closed. Reopen it to edit or answer.

How to call a particular function when a button is pressed in a gui other than guide gui?

4 views (last 30 days)
I have created a guide gui which contains a push button to open an image in a new gui which contains two push buttons - one is "open" in order to select an image from anywhere in the system and other button is "cancel". But if i donot select any image and press cancel button then i get following errors on my command window :-
??? Error using ==> fopen Invalid filename.
Error in ==> imread at 225 fid = fopen(filename, 'r');
Error in ==> Facerec>pushbutton1_Callback at 103 A=imread([pathname,filename]);
Error in ==> gui_mainfcn at 75 feval(varargin{:});
Error in ==> Facerec at 42 gui_mainfcn(gui_State, varargin{:});
??? Error while evaluating uicontrol Callback.
I do not want this error to be displayed. Instead I want to exit the gui mormally and return to my guide gui.
The code I am using for open an image in other gui is:
figure(1); [filename,pathname]=uigetfile('*.pgm'); A=imread([pathname,filename]); handles = guidata(hObject); handles.y=A; imshow(A); guidata(hObject, handles);
what should I add further so as to open image code when open button is pressed and return to guide gui when cancel button is pressed without displaying any error on command window?? Reply as soon as possible.

Answers (1)

Walter Roberson
Walter Roberson on 9 Apr 2012
if isempty(filename); return;

This question is closed.

Community Treasure Hunt

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

Start Hunting!