Parameters in GUI functions
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
Hi, I have this function to be used with GUI. But how do I pass over "parameter" to be used in another function (e.g RunButton_Callback)? If it is a text like in this example I found a workaround by set it to a textbox and then (in the other function) get it from that textbox. But what to do if it is a vector parameter?
function InputButton_Callback(hObject, eventdata, handle)
[Qfile]=uigetfile('*.txt','Select a file');
[parameter]=QImport(Qfile);
Antworten (1)
Geoff Hayes
am 10 Mär. 2016
nilsotto - just save the parameter to the handles structure using guidata as
function InputButton_Callback(hObject, eventdata, handle)
[Qfile]=uigetfile('*.txt','Select a file');
[parameter]=QImport(Qfile);
% save as a field within parameter
handles.parameter = parameter;
% update the structure
guidata(hObject, handles);
Now, in any other callback you can check to see if this field exists and then use it.
function someOther_Callback(hObject, eventdata, handle)
if isfield(handles, 'parameter')
% do something with handles.parameter
end
1 Kommentar
nilsotto
am 11 Mär. 2016
Diese Frage ist geschlossen.
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!