Making a simple gui
显示 更早的评论
I need to make a gui for another purpose, but I have never made one before in Matlab, so I figured I should make a test gui first. So I tried to make a simple gui that adds two numbers. I created 3 edit boxes and a push button that would execute the addition of boxes 1 and 2 when pressed. I give all the edit boxes the tags number1, number2, and number3 respectively. I then go to the callback function for the button and insert the following code:
a=get(handles.number1,'string');
b=get(handles.number2,'string');
a=str2double(a);
b=str2double(b);
c=a+b;
set(handles.number3,'string',num2str(c))
It keeps giving me an error for the very first line of that code (Struct contents reference from a non-struct array object). I have tried everything I could think of to make this work. I tried using str2num instead of str2double. I tried using the default tags and handles. I followed multiple tutorials that all essentially insert the code that I inserted. Oddly enough, it worked the first time I made it, but then when I came back to it it kept giving me this error. So at this point I don't what to do anymore.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!