您的当前位置:首页正文

随机信号分析与处理实验报告

2020-08-21 来源:爱go旅游网


随机信号分析与处理实

题目:对音频信号的随机处理 班级:0312412 姓名:肖文洲

学号:031241217 指导老师:钱楷 时间: 2014年11月25日

1

实验目的:

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;

2

(14)、截取声音信号的频谱; (15)、expcdf; (16)、periodogram; (17)、weibrnd; (18)、rand; (19)、自相关函数; (20)、截取信号的均方值。 实验步骤:

1、 打开MATLAB软件,然后输入guide创建一个

GUI文件。

2、 在已经创建好的GUI文件里面穿件所需要的.fig

面板(以学号 姓名格式命名)。入下图所示:

图为已经创建好的.fig面板

3

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.

4

%

% 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 EDIT gui_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}); 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 xiaowenzhou is made visible.

function xiaowenzhou_OpeningFcn(hObject, eventdata, handles, varargin)

5

% 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 xiaowenzhou handles.output = hObject;

% Update handles structure guidata(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 structure varargout{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)

6

% --- 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.

7

function pushbutton6_Callback(hObject, eventdata, handles) 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.

8

function pushbutton10_Callback(hObject, eventdata, handles) 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.

9

function pushbutton14_Callback(hObject, eventdata, handles) [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)

10

% --- 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:50

for j=1:1000

square(i)=square(i)+x(i,j).^2; end

square(i)=square(i)/1000; end

RMS=sum(square)/30; plot(square); grid;

11

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

12

(4) 误差函数

(5) axis

13

(6) 原始信号

(7) normpdfd

14

(8) unifpdf

(9) unifcdf

15

(10)raylpdf

(11)raylcdf

16

(12)exppdf

17

(13)截取声音信号的卷积

(14)expcdf

18

(15)periodogram

(16)weibrnd

19

(17)rand

(18)原始信号频谱

20

(19)自相关函数

(20)截取信号的均方值

21

实验总结:

随机信号分析与处理是研究随机信号的特点及其处理方法的专业基础课,是目标检测、估计、滤波等信号处理理论的基础。在通信、雷达、自动控制、随机振动、图像处理、气象预报、生物医学、地震信号处理等领域有着广泛的应用。随着信息技术的发展,随机信号分析与处理的理论和应用将日益广泛和深入。而通过本次的实验,让我明白了MATLAB软件的基础用法,对随机信号的各种简单处理办法及MATLAB中函数的调用、编程、调试等基础操作方法。可以说,本次实验对于大学阶段的我们有着深远的影响,着不仅仅是体现在我们对于MATLAB这一功能强大的软件的使用,更多的是对专业知识的理解与简单运用。本次实验室理论与实践相结合的真实写照。让我不仅体会到了理论基础的重要性,但是实践依然是我们学习生涯中的不可或缺的基石。在此,我被钱楷老师的教学方法及理论高度深深折服,感谢之情无以言表,不在赘述。

22

因篇幅问题不能全部显示,请点此查看更多更全内容