I can easily get this to work using popup dialogues, though I cannot seem to get this to work when I build a simple GUI from scratch. I can ALSO get this to work when I use GUIDE, but when I do it by hand, something fails.
Here is the code that I have written so far:
name_window = figure;
set(name_window, 'MenuBar', 'none',...
'Name','Please Enter Your Name',...
submitbtn = uicontrol('Style','pushbutton',...
'Position',[235 190 100 40],...
nameinput = uicontrol('Style', 'edit',...
'Position',[235 250 100 40],...
function submitbtn_Callback(hObject, eventdata, handles)
name = char(get(handles.nameinput_Callback, 'String'));
I am trying to figure out why my code is not working... I keep getting the same couple of error messages for everything that I try. Usually I am getting:
"Undefined function 'nameinput_Callback' for input arguments of type 'matlab.ui.control.UIControl'.
Error while evaluating UIControl Callback
Not enough input arguments.
Error in window>submitbtn_Callback (line 21) name = char(get(handles.nameinput_Callback, 'String'));
Error while evaluating UIControl Callback"
What exactly am I doing wrong? I've been reading through the code that was generated by GUIDE when I attempted this earlier, but I cannot seem to find anything that would help me.
All I want is that, when a user types something into the edit field and then clicks "Submit", the text that they entered in the edit box is then printed in the command window. But I cannot seem to get it to saved to the name variable.