Parameters in GUI functions
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
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);
댓글 수: 0
답변 (1개)
Geoff Hayes
2016년 3월 10일
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
nilsotto
2016년 3월 11일
이 질문은 마감되었습니다.
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!