随机信号分析与处理实验题目:对音频信号的随机处理班级:0312412姓名:肖文洲学号:031241217指导老师:钱楷时间:2014年11月25日实验目的:1、学会利用MATLAB模拟产生各类随机序列。
2、熟悉和掌握随机信号数字特征估计的基本方法。
3、熟悉掌握MATLAB的函数及函数调用、使用方法。
4、学会在MATLAB中创建GUI文件。
实验内容:1、选用任意一个音频信号作为实验对象,进行各种操作并画出信号和波形。
2、操作类型:(1)、概率密度;(2)、希尔伯特变换;(3)、误差函数;(4)、randn;(5)、原始信号频谱;(6)、axis;(7)、原始信号;(8)、normpdf;(9)、unifpdf;(10)、unifcdf;(11)、raylpdf;(12)、raylcdf;(13)、exppdf;(14)、截取声音信号的频谱;(15)、expcdf;(16)、periodogram;(17)、weibrnd;(18)、rand;(19)、自相关函数;(20)、截取信号的均方值。
实验步骤:1、打开MATLAB软件,然后输入guide创建一个GUI文件。
2、在已经创建好的GUI文件里面穿件所需要的.fig面板(以学号姓名格式命名)。
入下图所示:图为已经创建好的.fig面板3、右击“概率密度”,查看回调,然后点击“callback”.在相应的位置输入程序。
然后点击运行,出现下图:4、依次对后续操作方式进行类似的操作。
5、当完成所有按键的“callback”后,出现的均为上图。
实验程序:function varargout = xiaowenzhou(varargin)% XIAOWENZHOU M-file for xiaowenzhou.fig% XIAOWENZHOU, by itself, creates a new XIAOWENZHOU or raises the existing% singleton*.%% H = XIAOWENZHOU returns the handle to a new XIAOWENZHOU or the handle to% the existing singleton*.%% XIAOWENZHOU('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in XIAOWENZHOU.M with the given input arguments.%% XIAOWENZHOU('Property','Value',...) creates a new XIAOWENZHOU or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before xiaowenzhou_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to xiaowenzhou_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 xiaowenzhou% Last Modified by GUIDE v2.5 02-Dec-2014 23:14:41% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @xiaowenzhou_OpeningFcn, ...'gui_OutputFcn', @xiaowenzhou_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before xiaowenzhou is made visible.function xiaowenzhou_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 xiaowenzhou (see VARARGIN)% Choose default command line output for xiaowenzhouhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes xiaowenzhou wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line. function varargout = xiaowenzhou_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 structurevarargout{1} = handles.output;% --- Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)[y,Fs,bits]=wavread('Íõ·Æ.wav');y=y(1:5000);N=length(y);i=1:N;[f,i]=ksdensity(y);plot(i,f);grid;xlabel('x');ylabel('f(x)');axis();title('¸ÅÂÊÃܶÈ');% 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)% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)x=wavread('Íõ·Æ.wav');x=x(20000:40000);y=hilbert(x);y=real(y);plot(x);% 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)% --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)x=wavread('Íõ·Æ.wav');x=randn(500,1);plot(x);% 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)% --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)x=wavread('Íõ·Æ.wav');y=erf(x);plot(y);% 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)% --- Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)x=wavread('Íõ·Æ.wav');plot(x);axis([0 5000 -0.01 0.01]);% 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)% --- Executes on button press in pushbutton6.x=wavread('Íõ·Æ.wav');x=x(20000:40000);plot(x);% 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)% --- Executes on button press in pushbutton7.function pushbutton7_Callback(hObject, eventdata, handles)x=wavread('Íõ·Æ.wav');x=-6:0.01:7;y=normpdf(x,1,2);plot(y);% 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)% --- Executes on button press in pushbutton8.function pushbutton8_Callback(hObject, eventdata, handles)x=wavread('Íõ·Æ.wav');x=0:0.1:5;y=unifpdf(x,1,30);plot(y);% 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)% --- Executes on button press in pushbutton9.function pushbutton9_Callback(hObject, eventdata, handles)x=wavread('Íõ·Æ.wav');x=0:0.1:5;y=unifcdf(x,1,5);plot(y);% 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)% --- Executes on button press in pushbutton10.x=wavread('Íõ·Æ.wav');x=0:0.1:3;y=raylpdf(x,2);plot(y);% hObject handle to pushbutton10 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton11.function pushbutton11_Callback(hObject, eventdata, handles)x=wavread('Íõ·Æ.wav');x=0:0.1:3;y=raylcdf(x,10);plot(y);% 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)% --- Executes on button press in pushbutton12.function pushbutton12_Callback(hObject, eventdata, handles)x=wavread('Íõ·Æ.wav');x=0:0.01:5;y=exppdf(x,1);plot(y);% hObject handle to pushbutton12 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton13.function pushbutton13_Callback(hObject, eventdata, handles)x=wavread('Íõ·Æ.wav');x=0:0.01:5;y=expcdf(x,1);plot(y);% hObject handle to pushbutton13 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton14.[y,Fs,bits]=wavread('Íõ·Æ.wav');y1=y(1:1000);t=0:1/Fs:1;y1=periodogram(y1,[],1000,Fs);plot(y1);% hObject handle to pushbutton14 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton15.function pushbutton15_Callback(hObject, eventdata, handles)x=wavread('Íõ·Æ.wav');x=0:0.01:5;x=weibrnd(1,1.5,100,1);plot(x);% hObject handle to pushbutton15 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton16.function pushbutton16_Callback(hObject, eventdata, handles)x=wavread('Íõ·Æ.wav');x=rand(200,1);plot(x);% hObject handle to pushbutton16 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton17.function pushbutton17_Callback(hObject, eventdata, handles)[x,Fs,bits]=wavread ('Íõ·Æ.wav');x=x (:,1);X=fft (x,4096);magX=abs (X);angX=angle (X);plot (X); title ('Ô-ʼÐÅºÅÆµÆ×');% hObject handle to pushbutton17 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton18.function pushbutton18_Callback(hObject, eventdata, handles)[y,Fs,bits]=wavread('Íõ·Æ.wav');y=y(500:1000);h=[ones(1,20) zeros(1,20)];y2=conv(h,y);stem(y2,'.');grid;title('½ØÈ¡ÉùÒôÐźŵľí»ý');% hObject handle to pushbutton18 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton19.function pushbutton19_Callback(hObject, eventdata, handles)[y,Fs,bits]=wavread('Íõ·Æ.wav');y=y(1:5000);R=xcorr(y);plot(R);grid;title('×ÔÏà¹Øº¯Êý');% hObject handle to pushbutton19 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton20.function pushbutton20_Callback(hObject, eventdata, handles)[y,Fs,bits]=wavread('Íõ·Æ.wav');y=y(1:1000);n=length(y);x=randn(50,n);square=zeros(1,50);for i=1:50for j=1:1000square(i)=square(i)+x(i,j).^2;endsquare(i)=square(i)/1000;endRMS=sum(square)/30;plot(square);grid;title('½ØÈ¡ÉùÒôÐźŵľù·½Öµ');% hObject handle to pushbutton20 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes during object creation, after setting all properties. function pushbutton1_CreateFcn(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called 实验结果:(1)概率密度(2)希尔伯特变换(3)randn(4)误差函数(5)axis(6)原始信号(7)normpdfd(8)unifpdf(9)unifcdf(10)raylpdf(11)raylcdf(12)exppdf(13)截取声音信号的卷积(14)expcdf(15)periodogram(16)weibrnd(17)rand(18)原始信号频谱(19)自相关函数(20)截取信号的均方值实验总结:随机信号分析与处理是研究随机信号的特点及其处理方法的专业基础课,是目标检测、估计、滤波等信号处理理论的基础。