早教吧作业答案频道 -->其他-->
做了个MATLABGUI的文件,到buttongrop时候.第一次点击的时候有用,但是就是无法切换两个radiobutton.functionpushbutton1Callback(hObject,eventdata,handles)%hObjecthandletopushbutton1(seeGCBO)%eventdatareserved-tobed
题目详情
做了个MATLAB GUI的文件,到buttongrop时候.第一次点击的时候有用,但是就是无法切换两个radiobutton.
function pushbutton1_Callback(hObject,eventdata,handles)% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x1
global strname
[filename pathname]=uigetfile({'*.wav','ALL FILES(*.*)'},'选择文件');
if isequal([filename pathname],[0,0])
return;
end
strname=[pathname filename];%选择的声音文件路径和文件名
[x1,fs,bits]=wavread(strname);%temp表示声音数据 Fs表示频率
plot(handles.axes1,x1)
title('原始语音采样后时域信号');
% --- Executes when selected object is changed in uipanel1.
function uipanel1_SelectionChangeFcn(hObject,eventdata,handles)
% hObject handle to the selected object in uipanel1
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName:string 'SelectionChanged' (read only)
% OldValue:handle of the previously selected object or empty if none was selected
% NewValue:handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
global x1
global strname
strname=get(hObject,'string');
axes(handles.axes1);
switch strname
case '采样时域图形'
% axes(handles.axes3);
plot(handles.axes1,x1)
title('原始语音采样后时域信号');
case '频率响应图'
freqz(handles.axes1,x1) %绘制原始语音信号采样后的频率响应图
title('原始语音信号采样后频率响应图');
end
错误信息:
Error using ==> axesInvalid object handle
Error in ==> voice>uipanel1_SelectionChangeFcn at 104axes(handles.axes1);
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> voice at 42 gui_mainfcn(gui_State,varargin{:});
Error in ==>@(hObject,eventdata)voice('uipanel1_SelectionChangeFcn',get(hObject,'SelectedObject'),eventdata,guidata(get(hObject,'SelectedObject')))
Error in ==> hgfeval at 63
feval(fcn{1},varargin{:},fcn{2:end});
Error in ==> uitools.uibuttongroup.childAddedCbk>manageButtons at 80 hgfeval(cbk,source,evdata);
Error while evaluating uicontrol Callback
function pushbutton1_Callback(hObject,eventdata,handles)% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x1
global strname
[filename pathname]=uigetfile({'*.wav','ALL FILES(*.*)'},'选择文件');
if isequal([filename pathname],[0,0])
return;
end
strname=[pathname filename];%选择的声音文件路径和文件名
[x1,fs,bits]=wavread(strname);%temp表示声音数据 Fs表示频率
plot(handles.axes1,x1)
title('原始语音采样后时域信号');
% --- Executes when selected object is changed in uipanel1.
function uipanel1_SelectionChangeFcn(hObject,eventdata,handles)
% hObject handle to the selected object in uipanel1
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName:string 'SelectionChanged' (read only)
% OldValue:handle of the previously selected object or empty if none was selected
% NewValue:handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
global x1
global strname
strname=get(hObject,'string');
axes(handles.axes1);
switch strname
case '采样时域图形'
% axes(handles.axes3);
plot(handles.axes1,x1)
title('原始语音采样后时域信号');
case '频率响应图'
freqz(handles.axes1,x1) %绘制原始语音信号采样后的频率响应图
title('原始语音信号采样后频率响应图');
end
错误信息:
Error using ==> axesInvalid object handle
Error in ==> voice>uipanel1_SelectionChangeFcn at 104axes(handles.axes1);
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> voice at 42 gui_mainfcn(gui_State,varargin{:});
Error in ==>@(hObject,eventdata)voice('uipanel1_SelectionChangeFcn',get(hObject,'SelectedObject'),eventdata,guidata(get(hObject,'SelectedObject')))
Error in ==> hgfeval at 63
feval(fcn{1},varargin{:},fcn{2:end});
Error in ==> uitools.uibuttongroup.childAddedCbk>manageButtons at 80 hgfeval(cbk,source,evdata);
Error while evaluating uicontrol Callback
▼优质解答
答案和解析
错误信息表示axes(handles.axes1); 这句有问题,handles.axes1是不合法的句柄
改成这样试试axes(findobj('tag','axes1'));
改成这样试试axes(findobj('tag','axes1'));
看了 做了个MATLABGUI的文...的网友还看了以下:
已知字母组合成英语单词1、e e t t i n h r 2、e e r a t w h 3、o 2020-05-14 …
在等差数列{an}中,若s,t∈N※,有(as-at)/(s-t)=常数若s.t,r∈N※,且s, 2020-05-14 …
将字母组成单词,并译成汉语1.m,e,r,m,u,s,汉语2.u,l,t,e,c,u,r,汉语3. 2020-06-04 …
纵横字谜之英语暑假作业题(s)(o)(r)(r)(n)(g)(r)(e))(a)(k)(k)(e) 2020-06-06 …
求证:过三棱锥P-ABC的棱PA,PB,BC,AC的中点M.N.T.R的截面把该三棱锥的体积二等分 2020-06-17 …
过三棱锥P—ABC的PA,PB,BC,AC的中点M,N,T,R的截面把该三棱锥的体积二等分 2020-06-17 …
求证:过三棱锥P—ABC的PA,PB,BC,AC的中点M,N,T,R的截面把该三棱锥的体积二等分 2020-06-17 …
写单词,这些单词打乱顺序了!:1.d,f,e,n,i,f,e,r,t,()2.g,h,o,e,t, 2020-07-26 …
条件平差中求解的未知量是什么?设某一平差问题的观测量个数为n,必要观测数为t,若按条件平差法进行平 2020-07-29 …
什么是二项式的通式?在二项式定理(a+b)^n=C(n,0)a^n+C(n,1)a^(n-1)b+ 2020-07-31 …