matlab gui 的滑动条问题
看不到的我再写写源M程序%---Executesonslidermovement.functionslider1_Callback(hObject,eventdata,h...
看不到的我再写写
源M程序
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
%设置最小值和最大值
[y,fs,bits]=wavread('E:\dsp\luyin.wav');
h=get(handles.slider1,'Value'); %获得slider的当前值
set(handles.edit2,'string',num2str(h));%显示数值
sound(h*y,fs,bits);
问题是一堆error
>> levaev
Undefined function or variable 'd'.
Error in levaev>slider1_CreateFcn (line 182)
sound(d*y,fs,bits);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in levaev (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)levaev('slider1_CreateFcn',hObject,eventdata,guidata(hObject))
Error using struct2handle
Error while evaluating uicontrol CreateFcn
求解答 谢谢!!! 展开
源M程序
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
%设置最小值和最大值
[y,fs,bits]=wavread('E:\dsp\luyin.wav');
h=get(handles.slider1,'Value'); %获得slider的当前值
set(handles.edit2,'string',num2str(h));%显示数值
sound(h*y,fs,bits);
问题是一堆error
>> levaev
Undefined function or variable 'd'.
Error in levaev>slider1_CreateFcn (line 182)
sound(d*y,fs,bits);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in levaev (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)levaev('slider1_CreateFcn',hObject,eventdata,guidata(hObject))
Error using struct2handle
Error while evaluating uicontrol CreateFcn
求解答 谢谢!!! 展开
1个回答
展开全部
出错的位置在182行slider1_CreateFcn部分,你贴的图和代码都是slider1_Callback部分的,能起什么作用?
从报错信息看,182行用到了变量d,但是变量没定义。
从报错信息看,182行用到了变量d,但是变量没定义。
更多追问追答
追问
追答
你把最后一行删掉试试:
sound(d*y,fs,bits);
这一行里面有d*y,而d未定义,所以会抱错。即使d定义了,fs、bits未定义仍然会报错。
slider1_CreateFcn只在创建滑动条的时候执行一次,删掉这行没其它影响。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询