Hello. I have the following simple GUI design.
The upper text box (which tag is input) is where the input number is entered while the lower text box (tag is output) presents the place where the output value appears.
The center pop-up menu (tag is select) has three calculation option with the input number; square, cubic and exponential. The output value calculated according to the choice of pop-up menu should be shown in the lower text box.
The corresponding m file is the following.
function select_Callback(hObject, eventdata, handles)
n = str2double(get(handles.input,'String'));
choice = get(hObject,'Value');
switch choice
case 1
y = n^2;
case 2
y = n^3;
case 3
y = exp(n);
end
set(handles.output,'string',y);
I didn't touch anything on the other part of the code.
I guessed there is no defect in this code unless I saw the error message like
Error using hg.figure/set
The name 'string' is not an accessible property for an instance of class
'figure'.
Error in practise_2>select_Callback (line 117)
set(handles.output,'string',y);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in practise_2 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)practise_2('select_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
after the code running. Please tell me anything wrong on my code
In addition, could you tell me how I understand the command 'set'.
How is set used to give the output to the lower textbox?