function interfaz_OpeningFcn(hObject, eventdata, handles, varargin)
set(handles.low,'Value',0.5);
handles.low=initialvalue;
guidata(hObject, handles);
我想制作一个按钮,这样当你按下它时,它会使滑块回到初始值。我试过这种方式:
function eq_reset_Callback(hObject, eventdata, handles)
set(handles.low,'Value',0.5);
handles.low=initialvalue;
guidata(hObject, handles);
这会导致下一个错误:
Error using handle.handle/set
Invalid or deleted object.
Error in interfaz>eq_reset_Callback (line 644)
set(handles.low,'Value',0.5);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in interfaz (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)interfaz('eq_reset_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
为什么会这样?其他方法可以做到吗?
答案 0 :(得分:0)
请尝试以下代码:
开场功能:
function interfaz_OpeningFcn(hObject, eventdata, handles, varargin)
handles.low_initialvalue = 0.5;
set(handles.low,'Value',handles.low_initialvalue);
guidata(hObject, handles);
按钮回调功能:
function eq_reset_Callback(hObject, eventdata, handles)
set(handles.low,'Value',handles.low_initialvalue);
guidata(hObject, handles);