Getting a variable from an Edit box, using a push button.
2 ビュー (過去 30 日間)
古いコメントを表示
Hello all, I am fairly new to matlab and I have a bit of a snafu.
I have a snippet of code that relies on pulling someones age from a edit box, and placing it in a variable. I put the callback that triggers it in the push button.
This is my code.
function AgeEdit_Callback(hObject, eventdata, handles)
code that doesn't matter.. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function AgePushButton_Callback(hObject, eventdata, handles)
age = str2double(get(handles.AgeEdit , 'String'));
My issue that Im encountering is that when i type in a value into the age edit box, then hit the button, no variable pops up in my workspace and i also get no errors. I am genuinely stumped. Any and all ideas are welcome.
0 件のコメント
採用された回答
CS Researcher
2016 年 5 月 1 日
It will not go to your workspace directly. To save the value to the workspace do this:
age = str2double(get(handles.AgeEdit , 'String'));
assignin('base','age',age);
Then you go to the workspace and use the age variable.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!