??? Undefined variable "handles" or class "handles.slider1". in Guide for a function
显示 更早的评论
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?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Function Handles 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!