www.pudn.com > dspproject.rar > jiangzao.m, change:2016-10-23,size:25037b
function varargout = jiangzao(varargin) % JIANGZAO MATLAB code for jiangzao.fig % JIANGZAO, by itself, creates a new JIANGZAO or raises the existing % singleton*. % % H = JIANGZAO returns the handle to a new JIANGZAO or the handle to % the existing singleton*. % % JIANGZAO('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in JIANGZAO.M with the given input arguments. % % JIANGZAO('Property','Value',...) creates a new JIANGZAO or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before jiangzao_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to jiangzao_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help jiangzao % Last Modified by GUIDE v2.5 22-Oct-2016 18:56:42 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @jiangzao_OpeningFcn, ... 'gui_OutputFcn', @jiangzao_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before jiangzao is made visible. function jiangzao_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to jiangzao (see VARARGIN) % Choose default command line output for jiangzao handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes jiangzao wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = jiangzao_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in pushbutton1. 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 fpath snr [y,fs]=wavread(fpath); fq=fs;%话音回放 n = length (y); a=str2num(get(handles.edit16,'String')); Ft=str2num(get(handles.edit6,'String'));; Fp=str2num(get(handles.edit7,'String'));; Fs=str2num(get(handles.edit8,'String'));; wp=2*pi*Fp/Ft; ws=2*pi*Fs/Ft; fp=2*Ft*tan(wp/2); fs=2*Fs*tan(wp/2); [n11,wn11]=buttord(wp,ws,1,50,'s'); %求低通滤波器的阶数和截止频率 [b11,a11]=butter(n11,wn11,'s'); %求S域的频率响应的参数 [num11,den11]=bilinear(b11,a11,0.5); %利用双线性变换实现频率响应S域到Z域的变换 [h,w]=freqz(num11,den11); %根据参数求出频率响应 z11=filter(num11,den11,y); sound(z11*a,fq); n=length(z11); Y=fft(z11,n); %傅里叶变换 N=length(z11)+1; Y=fft(z11);%做FFT变换,以下为绘图函数 Y=abs(Y); Y=Y(1:N/2); f=(0:N-1)*fs/N; f=f(1:N/2); plot(handles.axes4,Y); xlabel('Hz'); ylabel('幅值'); plot(handles.axes2,z11); snr=SNR_singlech(Y,z11); % 计算维纳滤波后的信噪比 set(handles.text22,'string',snr);%在静态文本框中显示信噪比 % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global fpath [y,fs]=wavread(fpath); fq=fs;%话音回放 n = length (y) a=str2num(get(handles.edit16,'String')); fpl=str2num(get(handles.edit2,'String')); fpu=str2num(get(handles.edit4,'String')); fsl=str2num(get(handles.edit3,'String')); fsu=str2num(get(handles.edit5,'String')); wp3=[2*fpl/fs,2*fpu/fs]; ws3=[2*fsl/fs,2*fsu/fs]; rp=1; as=100; [N3,wp3]=ellipord(wp3,ws3,rp,as); %计算椭圆带通模拟滤波器的阶数和通带边界频率 [B3,A3]=ellip(N3,rp,as,wp3); %计算带通滤波器模拟滤波器系统函数系数 y3=filter(B3,A3,y); sound(y3*a,fq); n=length(y3); Y=fft(y3,n); %傅里叶变换 N=length(y3)+1; Y=fft(y3);%做FFT变换,以下为绘图函数 Y=abs(Y); Y=Y(1:N/2); f=(0:N-1)*fs/N; f=f(1:N/2); plot(handles.axes4,Y); xlabel('Hz'); ylabel('幅值'); plot(handles.axes2,y3); % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global fpath [y,fs]=wavread(fpath); fq=fs;%话音回放 n = length (y) a=str2num(get(handles.edit16,'String')); Ft=str2num(get(handles.edit13,'String'));; Fp=str2num(get(handles.edit14,'String'));; Fs=str2num(get(handles.edit15,'String'));; wp1=tan(pi*Fp/Ft);%高通到低通滤波器参数转换? ws1=tan(pi*Fs/Ft); wp=1; ws=wp1*wp/ws1; [n13,wn13]=cheb1ord(wp,ws,1,100,'s');%求模拟的低通滤波器阶数和截止频率? [b13,a13]=cheby1(n13,1,wn13,'s');%求S域的频率响应的参数? [num,den]=lp2hp(b13,a13,wn13);%将S域低通参数转为高通的? [num13,den13]=bilinear(num,den,0.5);%利用双线性变换实现频率响应S域到Z域转换? [h,w]=freqz(num13,den13); z11=filter(num13,den13,y); sound(z11*a,fq); n=length(z11); Y=fft(z11,n); %傅里叶变换 N=length(z11)+1; Y=fft(z11);%做FFT变换,以下为绘图函数 Y=abs(Y); Y=Y(1:N/2); f=(0:N-1)*fs/N; f=f(1:N/2); plot(handles.axes4,Y); xlabel('Hz'); ylabel('幅值'); plot(handles.axes2,z11); snr=SNR_singlech(Y,z11); % 计算维纳滤波后的信噪比 set(handles.text22,'string',snr);%在静态文本框中显示信噪比 % --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) ButtonName=questdlg('是否开始录音?','MATLAB quest','Yes','No','Yes'); switch ButtonName case 'Yes' prompt={'输入录音时间:','输入采样率'};%设置提示字符串 name='Enter trapeaia Data';%设置标题 numlines=1;%指定输入数据的行数 defAns={'6','44100'};%设定默认值 Resize='on';%设定对话框尺寸可调节 answer=inputdlg(prompt,name,numlines,defAns,'on');%创建输入对话框 duration = str2num(answer{1}); fs = str2num(answer{2}); h = waitbar(0,'录音中,请稍后...'); data=audiorecorder(fs,16,2); recordblocking(data,duration); y =getaudiodata(data,'int16'); wavwrite(y,fs,'d:\luyinzao.wav'); waitbar(1,h,'录音完毕'); end % --- Executes on button press in pushbutton5. function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global fpath3 [filename, pathname] = uigetfile('*.wav','选择声音文件'); if isequal(filename,0)||isequal(pathname,0) %判断是否打开音频 return; end; fpath3=[pathname filename]; [y,fs]=wavread(fpath3); audioplayer(y,fs); n=length(y); Y=fft(y,n); %傅里叶变换 N=length(y)+1; Y=fft(y);%做FFT变换,以下为绘图函数 Y=abs(Y); Y=Y(1:N/2); f=(0:N-1)*fs/N; f=f(1:N/2); plot(handles.axes3,Y); xlabel('Hz'); ylabel('幅值'); plot(handles.axes1,y); % --- Executes on button press in pushbutton6. function pushbutton6_Callback(hObject, eventdata, handles) % hObject handle to pushbutton6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) main; % --- Executes on button press in pushbutton7. function pushbutton7_Callback(hObject, eventdata, handles) % hObject handle to pushbutton7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global fpath3 %小波降噪 [s,fs]=wavread(fpath3); N=length(s); t=s'; [thr,sorh,keepapp]=ddencmp('den','wv',t); [c,l]=wavedec(t,5,'sym6'); xd=wdencmp('gbl',c,l,'sym6',5,thr,sorh,keepapp); sound(xd,2*fs); %snr=SNR_singlech(s,xd); % 计算维纳滤波后的信噪比 %set(handles.text23,'string',snr);%在静态文本框中显示信噪比 n=length(xd); Y=fft(xd,n); %傅里叶变换 N=length(xd)+1; Y=fft(xd);%做FFT变换,以下为绘图函数 Y=abs(Y); Y=Y(1:N/2); f=(0:N-1)*fs/N; f=f(1:N/2); plot(handles.axes4,Y); xlabel('Hz'); ylabel('幅值'); plot(handles.axes2,xd); function edit6_Callback(hObject, eventdata, handles) % hObject handle to edit6 (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,'String') returns contents of edit6 as text % str2double(get(hObject,'String')) returns contents of edit6 as a double % --- Executes during object creation, after setting all properties. function edit6_CreateFcn(hObject, eventdata, handles) % hObject handle to edit6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit7_Callback(hObject, eventdata, handles) % hObject handle to edit7 (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,'String') returns contents of edit7 as text % str2double(get(hObject,'String')) returns contents of edit7 as a double % --- Executes during object creation, after setting all properties. function edit7_CreateFcn(hObject, eventdata, handles) % hObject handle to edit7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit8_Callback(hObject, eventdata, handles) % hObject handle to edit8 (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,'String') returns contents of edit8 as text % str2double(get(hObject,'String')) returns contents of edit8 as a double % --- Executes during object creation, after setting all properties. function edit8_CreateFcn(hObject, eventdata, handles) % hObject handle to edit8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit9_Callback(hObject, eventdata, handles) % hObject handle to edit9 (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,'String') returns contents of edit9 as text % str2double(get(hObject,'String')) returns contents of edit9 as a double % --- Executes during object creation, after setting all properties. function edit9_CreateFcn(hObject, eventdata, handles) % hObject handle to edit9 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit2_Callback(hObject, eventdata, handles) % hObject handle to edit2 (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,'String') returns contents of edit2 as text % str2double(get(hObject,'String')) returns contents of edit2 as a double % --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (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,'String') returns contents of edit3 as text % str2double(get(hObject,'String')) returns contents of edit3 as a double % --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (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,'String') returns contents of edit4 as text % str2double(get(hObject,'String')) returns contents of edit4 as a double % --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit5_Callback(hObject, eventdata, handles) % hObject handle to edit5 (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,'String') returns contents of edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double % --- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit13_Callback(hObject, eventdata, handles) % hObject handle to edit13 (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,'String') returns contents of edit13 as text % str2double(get(hObject,'String')) returns contents of edit13 as a double % --- Executes during object creation, after setting all properties. function edit13_CreateFcn(hObject, eventdata, handles) % hObject handle to edit13 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit14_Callback(hObject, eventdata, handles) % hObject handle to edit14 (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,'String') returns contents of edit14 as text % str2double(get(hObject,'String')) returns contents of edit14 as a double % --- Executes during object creation, after setting all properties. function edit14_CreateFcn(hObject, eventdata, handles) % hObject handle to edit14 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit15_Callback(hObject, eventdata, handles) % hObject handle to edit15 (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,'String') returns contents of edit15 as text % str2double(get(hObject,'String')) returns contents of edit15 as a double % --- Executes during object creation, after setting all properties. function edit15_CreateFcn(hObject, eventdata, handles) % hObject handle to edit15 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in pushbutton8. function pushbutton8_Callback(hObject, eventdata, handles) % hObject handle to pushbutton8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) function edit16_Callback(hObject, eventdata, handles) % hObject handle to edit16 (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,'String') returns contents of edit16 as text % str2double(get(hObject,'String')) returns contents of edit16 as a double % --- Executes during object creation, after setting all properties. function edit16_CreateFcn(hObject, eventdata, handles) % hObject handle to edit16 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in pushbutton9. function pushbutton9_Callback(hObject, eventdata, handles) % hObject handle to pushbutton9 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global fpath3 %维纳滤波 [xx,fs]=audioread(fpath3);% 读入数据文件 xx=xx(:,1); xx=xx-mean(xx); % mean:求矩阵各列均值 消除直流分量 x=xx/max(abs(xx)); % 幅值归一化 N=length(x); % 信号长度 time=(0:N-1)/fs; % 设置时间 Y=fft(x,N); %傅里叶变换 n=length(x)+1; Y=fft(x);%做FFT变换,以下为绘图函数 Y=abs(Y); Y=Y(1:N/2); f=(0:N-1)*fs/N; f=f(1:N/2); IS=.15; % 设置IS % 调用WienerScalart96m_2函数做维纳滤波 output=WienerScalart96m_2(xx,fs,IS,0.12); ol=length(output); % 把output补到与x等长 if ol<N output=[output; zeros(N-ol,1)]; end snr=SNR_singlech(x,output); % 计算维纳滤波后的信噪比 fp1=1200; fs1=2000; wp1=2*fp1/fs;%设定低通滤波器通带截止频率和阻带截止频率 ws1=2*fs1/fs; rp=1; as=100; [N1,wp1]=ellipord(wp1,ws1,rp,as);%计算椭圆低通模拟滤波器的阶数和通带边界频率 [B,A]=ellip(N1,rp,as,wp1);%计算低通滤波器模拟滤波器系统函数系数 output1=filter(B,A,output); M=length(output); % 信号长度 time1=(0:M-1)/fs; % 设置时间 Y2=fft(output,M); %傅里叶变换 m=length(M)+1; Y2=fft(output);%做FFT变换,以下为绘图函数 Y2=abs(Y2); Y2=Y2(1:M/2); f2=(0:M-1)*fs/M; f2=f2(1:M/2); %subplot(2,2,1) %plot(time,x,'k'); grid; axis tight; %title('噪音语音波形'); ylabel('幅值'); xlabel('时间/s'); %subplot(2,2,2) %plot(time,output,'r'); grid; axis tight; %title('去噪后语音波形'); ylabel('幅值'); xlabel('时间/s'); sound(output1,fs); plot(handles.axes2,output); xlabel('Hz'); ylabel('幅值'); plot(handles.axes4,Y2); set(handles.text22,'string',snr); function edit17_Callback(hObject, eventdata, handles) % hObject handle to edit17 (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,'String') returns contents of edit17 as text % str2double(get(hObject,'String')) returns contents of edit17 as a double % --- Executes during object creation, after setting all properties. function edit17_CreateFcn(hObject, eventdata, handles) % hObject handle to edit17 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes during object creation, after setting all properties. function text22_CreateFcn(hObject, eventdata, handles) % hObject handle to text22 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % --- Executes on button press in pushbutton11. function pushbutton11_Callback(hObject, eventdata, handles) % hObject handle to pushbutton11 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global fpath3 %完美去风声 [Original,fs]=audioread(fpath3);%修改文件路径 ts=1/fs; N=length(Original)-1; t=0:1/fs:N/fs; Nfft=N; df=fs/Nfft; fk=(-Nfft/2:Nfft/2-1)*df; a1=1,a2=-1,b1=1,b2=-1; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SoundLeft=Original(:,1); SoundRight=Original(:,2); SoundLeft_f=ts*fftshift(fft(SoundLeft,N)); SoundRight_f=ts*fftshift(fft(SoundRight,N)); % Sound=SoundLeft-SoundRight; NewLeft=a1*SoundLeft+a2*SoundRight; NewRight=b1*SoundLeft+b2*SoundRight; Sound(:,1)=NewLeft; Sound(:,2)=NewRight; sound(Sound,fs); n=length(Sound); Y=fft(Sound,n); %傅里叶变换 N=length(Sound)+1; Y=fft(Sound);%做FFT变换,以下为绘图函数 Y=abs(Y); Y=Y(1:N/2); f=(0:N-1)*fs/N; f=f(1:N/2); plot(handles.axes4,Y); xlabel('Hz'); ylabel('幅值'); plot(handles.axes2,Sound);