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!