Parameters in GUI functions
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
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);
Respuestas (1)
Geoff Hayes
el 10 de Mzo. de 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 comentario
nilsotto
el 11 de Mzo. de 2016
La pregunta está cerrada.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!