Making a simple gui
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!