Info
この質問は閉じられています。 編集または回答するには再度開いてください。
GUIDE - using the data of a Textbox to use it in other functions in the main
1 回表示 (過去 30 日間)
古いコメントを表示
I want to use the variable minVelocity in my main. the variable will me entered in the textbox of my gui after I press execute it will be saved.
But I can not use it in my main it does not work.
0 件のコメント
回答 (1 件)
Image Analyst
2019 年 12 月 13 日
Just call this code to get minVelocity whenever you need it
minVelocity = str2double(handles.minVelocity.String);
The function will have to have access to the handles structure, which all GUI component callbacks will have.
6 件のコメント
Image Analyst
2019 年 12 月 17 日
Replace this
% --- Executes on button press in execute_button.
function execute_button_Callback(hObject, eventdata, handles)
minVelocity = str2double(get(handles.minVelocity_text, 'string'));
% Store the data in the "UserData" property of the GUI Figure
% This assumes that the hObject is a child of the GUI figure
data.minVelocity = minVelocity;
hObject.Parent.UserData = data;
disp(minVelocity)
Analysis_Main
with this
% --- Executes on button press in execute_button.
function execute_button_Callback(hObject, eventdata, handles)
minVelocity = str2double(get(handles.minVelocity_text, 'string'));
% Store the data in the "UserData" property of the GUI Figure
% This assumes that the hObject is a child of the GUI figure
data.minVelocity = minVelocity;
hObject.Parent.UserData = data;
disp(minVelocity)
handles = Analysis_Main(handles);
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!