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!