question on callback between pushbuttons ? Uigetfile to load automatically ?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I have created an GUI with name autoruncheck and i have 2 pushbuttons. With pushbutton1, I call pushbutton2 and I have chosen to load an mat file in pushbutton2. What i need is, pushbutton2 should automatically load the mat file without user loading it. How it can be done. I would also want to know the way I callback Pushbutton2 is correct ? is there any other way for callback ?
function pushbutton1_Callback(hObject, eventdata, handles)
autoruncheck('pushbutton2_Callback',handles.pushbutton2,[],handles)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
[FileName,PathName] = uigetfile('Step02.mat','Select mat file');
NAME = [PathName,FileName];
evalin('base',['load ' NAME]);
3 Commenti
Risposte (1)
Image Analyst
il 5 Lug 2012
Modificato: Image Analyst
il 5 Lug 2012
I'd have pushbutton1 say "Specify File then Process..." and call uigetdir and then a function called ProcessFile(fullFileName). Pushbutton2's caption would say "Process default file" and would just assign some default fullFileName and then call the same function ProcessFile(fullFileName).
ProcessFile(fullFileName) would be a function that you write that takes whatever filename is passed, however it might be created, in and do something with it. So the pushbutton 1 and 2 are merely different ways of getting that filename, one via the user browsing, and the second "automatically" by assigning some default filename.
2 Commenti
Image Analyst
il 5 Lug 2012
Yes. Same basic process. Just create a new function that does what's inside the pushbutton 1 callback - let's say it's SpecifyFileAndProcess(). Then you just call that function both within the OpeningFcn() start up code, and within the pushbutton 1 callback. You will need to pass in handles in the argument list if you need to use it inside SpecifyFileAndProcess(), say if you need to get the values of any sliders, edit fields, radio buttons, checkboxes, etc..
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!