MATLABGUI声音图像处理20个模块的程序.docx
《MATLABGUI声音图像处理20个模块的程序.docx》由会员分享,可在线阅读,更多相关《MATLABGUI声音图像处理20个模块的程序.docx(16页珍藏版)》请在冰豆网上搜索。
![MATLABGUI声音图像处理20个模块的程序.docx](https://file1.bdocx.com/fileroot1/2023-6/1/b890c68b-9a7c-4c4a-9f6d-c04d10c926cd/b890c68b-9a7c-4c4a-9f6d-c04d10c926cd1.gif)
MATLABGUI声音图像处理20个模块的程序
%---Executesonbuttonpressinpushbutton1.
functionpushbutton1_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton1(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
Forpersonaluseonlyinstudyandresearch;notforcommercialuse
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
axes(handles.axes1);
Forpersonaluseonlyinstudyandresearch;notforcommercialuse
plot(y);
grid;
title('原始声音信号的波形');
Forpersonaluseonlyinstudyandresearch;notforcommercialuse
y1=y(100:
199);
axes(handles.axes2);
plot(y1);
grid;
title('截取声音信号的波形');
%---Executesonbuttonpressinpushbutton18.
functionpushbutton18_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton18(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
y1=y(100:
199);
axes(handles.axes1);
plot(y1);
grid;
title('截取声音信号的波形');
t=0:
0.01:
2;
y2=abs(fft(y1,512));
f=100*(0:
256)/512;%进行对应的频率转换
axes(handles.axes2);
plot(f,y2(1:
257));
grid;
title('FFT变换后波形');
%---Executesonbuttonpressinpushbutton2.
functionpushbutton2_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton2(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
axes(handles.axes1);
plot(y);
grid;
title('原始声音信号的波形');
y1=fft(y,100);
f=0:
Fs/99:
Fs;
axes(handles.axes2);
plot(f,abs(y1));
grid;
title('原始声音信号的频谱');
%---Executesonbuttonpressinpushbutton3.
functionpushbutton3_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton3(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
axes(handles.axes1);
plot(y);
grid;
title('原始声音信号的波形');
y1=fft(y,1000);
y2=abs(y1);
axes(handles.axes2);
plot(y2);
grid;
title('原始声音信号的幅值');
xlabel('Hz');
ylabel('FuZhi');
%---Executesonbuttonpressinpushbutton4.
functionpushbutton4_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton4(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
axes(handles.axes1);
plot(y);
grid;
title('原始声音信号的波形');
y1=fft(y,1000);
y2=angle(y1);
axes(handles.axes2);
plot(y2);
grid;
title('原始声音信号的相位');
%---Executesonbuttonpressinpushbutton5.
functionpushbutton5_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton5(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
axes(handles.axes1);
plot(y);
grid;
title('原始声音信号的波形');
t=0:
0.001:
1;
y=randn(size(t));
axes(handles.axes2);
plot(y),axis([01000-55]),gridon;
title('加高斯白噪声的波形')
%---Executesonbuttonpressinpushbutton6.
functionpushbutton6_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton6(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
y1=y(1:
1000);
axes(handles.axes1);
plot(y1);
grid;
title('原始声音信号的波形');
axes(handles.axes2);
hist(y1);
axis();
title('直方图');
%---Executesonbuttonpressinpushbutton7.
functionpushbutton7_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton7(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
y1=y(1:
1000);
axes(handles.axes1);
plot(y1);
grid;
title('截取声音信号的波形');
N=length(y1);
i=1:
N;
[f,i]=ksdensity(y1);
axes(handles.axes2);
plot(i,f);
grid;
xlabel('x');
ylabel('f(x)');
axis();
title('概率密度');
%---Executesonbuttonpressinpushbutton8.
functionpushbutton8_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton8(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
y1=y(1:
1000);
axes(handles.axes1);
plot(y1);
grid;
title('截取声音信号的波形');
R=xcorr(y1);
axes(handles.axes2);
plot(R);
grid;
title('自相关函数');
%---Executesonbuttonpressinpushbutton9.
functionpushbutton9_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton9(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
y1=y(1:
1000);
axes(handles.axes1);
plot(y1);
grid;
title('截取声音信号的波形');
t=0:
1/Fs:
1;
axes(handles.axes2);
y2=periodogram(y1,[],1000,Fs);
plot(y2);
axis();
gridon
title('功率谱');
%---Executesonbuttonpressinpushbutton10.
functionpushbutton10_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton10(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
y1=y(1:
1000);
axes(handles.axes1);
plot(y1);
grid;
title('截取声音信号的波形');
n=length(y1);
x=randn(50,n);
average=zeros(1,50);
fori=1:
50
forj=1:
1000
average(i)=average(i)+x(i,j);
end
average(i)=average(i)/1000;
end
EX=sum(average)/50;
axes(handles.axes2);
plot(average);
grid;
title('截取声音信号的均值')
%---Executesonbuttonpressinpushbutton11.
functionpushbutton11_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton11(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
y1=y(1:
1000);
axes(handles.axes1);
plot(y1);
grid;
title('截取声音信号的波形');
n=length(y1);
x=randn(50,n);
average=zeros(1,50);
fori=1:
50
forj=1:
1000
average(i)=average(i)+x(i,j);
end
average(i)=average(i)/1000;
end
EX=sum(average)/50;
variance=zeros(1,50);
fori=1:
50
forj=1:
1000
variance(i)=variance(i)+(x(i,j)-average(i)).^2;
end
variance(i)=variance(i)/1000;
end
DX=sum(variance)/50;
axes(handles.axes2);
plot(variance);
grid;
title('截取声音信号的方差');
%---Executesonbuttonpressinpushbutton12.
functionpushbutton12_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton12(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
y1=y(1:
1000);
axes(handles.axes1);
plot(y1);
grid;
title('截取声音信号的波形');
n=length(y1);
x=randn(50,n);
square=zeros(1,50);
fori=1:
50
forj=1:
1000
square(i)=square(i)+x(i,j).^2;
end
square(i)=square(i)/1000;
end
RMS=sum(square)/50;
axes(handles.axes2);
plot(square);
grid;
title('截取声音信号的均方值');
%---Executesonbuttonpressinpushbutton13.
functionpushbutton13_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton13(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
y1=y(100:
199);
axes(handles.axes1);
plot(y1);
grid;
title('截取声音信号的波形');
h=[ones(1,10)zeros(1,10)];
y2=conv(h,y1);
axes(handles.axes2);
stem(y2,'.');
grid;
title('截取声音信号的卷积');
%---Executesonbuttonpressinpushbutton14.
functionpushbutton14_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton14(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
y1=y(100:
199);
axes(handles.axes1);
plot(y1);
grid;
title('截取声音信号的波形');
A=[1,-1.8237,0.9801];
B=[1/100.49,0,-1/100.49];
Y=filter(B,A,y1);%对声音滤波
axes(handles.axes2);
stem(Y,'.');
grid;
title('截取声音信号的响应');
%---Executesonbuttonpressinpushbutton15.
functionpushbutton15_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton15(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
y1=y(100:
199);
axes(handles.axes1);
plot(y1);
grid;
title('截取声音信号的波形');
Y=fft(y1,50);
axes(handles.axes2);
stem(Y,'.');
axis();
grid;
title('截取声音信号的DFT波形');
xlabel('w/pi');
ylabel('Fuzhi');
%---Executesonbuttonpressinpushbutton16.
functionpushbutton16_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton16(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
y=wavread('H:
\cw\cw.wav');
[y,Fs,bits]=wavread('H:
\cw\cw.wav')
y1=y(100:
199);
axes(handles.axes1);
plot(y1);
grid;
title('截取声音信号的波形');
n=length(y1);
window=boxcar(n);
[h,w]=freqz(window,1);%求数字滤波器的复频率响应
axes(handles.axes2);
stem(window);
title('加矩形窗后的波形');
figure
(1);
plot(w/pi,20*log(abs(h)/abs(h
(1))));
grid;
title('加矩形窗后的频率分析');
%---Executesonbuttonpressinpushbutton17.
functionpushbutton17_Callbac