??? Undefined variable "handles" or class "handles.slider1". in Guide for a function
Show older comments
I have 3 sliders. When I move one of the sliders I want to get the summ of Sliders Values. But summing of the Sliders Value I want to realise in separate function.
function slider1_Callback(hObject, eventdata, handles)
result;
function slider2_Callback(hObject, eventdata, handles)
result;
function slider3_Callback(hObject, eventdata, handles)
result;
function result
x=get(handles.slider1,'Value'); %position of X slider
set(handles.text1,'String', num2str(x));
y=get(handles.slider2,'Value'); %position of Y slider
set(handles.text2,'String', num2str(y));
z=get(handles.slider3,'Value'); %position of Z slider
set(handles.text3,'String', num2str(z));
result=x+y+z;
set(handles.textResult,'String', num2str(result));
If I moves one of the slider (the 3rd for example):
??? Undefined variable "handles" or class
"handles.slider1".
Error in ==> subfunction>result at 167
x=get(handles.slider1,'Value');
%position of X slider
Error in ==> subfunction>slider3_Callback at 151
result;
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> subfunction at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)subfunction('slider3_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
I try to add (hObject, eventdata, handles) to result function, but it doesn`t help. I`m not realy good in GUIDE functions, can someone help me, please?
Accepted Answer
More Answers (0)
Categories
Find more on Function Handles 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!