✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
随着数字化技术的快速、深入发展,人们对数字化电子产品所产生的图像、图形以及声音等质量的要求越来越高。在实时数字处理过程中,往往需要对目标信号进行滤波处理,以满足用户对信号的要求。MATLAB 是一个数据分析和处理功能十分强大的工程实用软件,它的滤波器设计工具箱为实现声音信号的数字滤波提供了十分方便的函数和命令。本文将介绍基于MATLAB设计出的一种实用的数字滤波器,并对其功能进行扩展,设计出一种均衡器。
1 算法原理
滤波器的种类很多,按所通过信号的频段分为低通、高通、带通和带阻滤波器四种。低通滤波器:它允许信号中的低频或直流分量通过,抑制高频分量或干扰和噪声。高通滤波器:它允许信号中的高频分量通过,抑制低频或直流分量。带通滤波器:它允许一定频段的信号通过,抑制低于或高于该频段的信号、干扰和噪声。带阻滤波器:它抑制一定频段内的信号,允许该频段以外的信号通过。
上述每种滤波器又可以分为模拟滤波器和数字滤波器。如果滤波器的输入输出都是数字信号,则这样的滤波器称之为数字滤波器。根据数字滤波器冲激响应的时域特性,可将数字滤波器分为两种,即无限长冲激响应(IIR)滤波器和有限长冲激响应(FIR)滤波器。
⛄ 部分代码
function varargout = Equalizer(varargin)
% EQUALIZER MATLAB code for Equalizer.fig
% EQUALIZER, by itself, creates a new EQUALIZER or raises the existing
% singleton*.
%
% H = EQUALIZER returns the handle to a new EQUALIZER or the handle to
% the existing singleton*.
%
% EQUALIZER('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in EQUALIZER.M with the given input arguments.
%
% EQUALIZER('Property','Value',...) creates a new EQUALIZER or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Equalizer_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Equalizer_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 Equalizer
% Last Modified by GUIDE v2.5 08-Dec-2011 12:41:42
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Equalizer_OpeningFcn, ...
'gui_OutputFcn', @Equalizer_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 Equalizer is made visible.
function Equalizer_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 Equalizer (see VARARGIN)
% Choose default command line output for Equalizer
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
f=linspace(0,20000,20000);
yf=1.*(f<=5000)+0.*(f>5000);
plot(handles.axes5,f,yf,'m','LineWidth',2);
axis(handles.axes5,[0,20000,0,1.2]);
xlabel(handles.axes5,'Freqency(Hz)','fontweight','bold');
ylabel(handles.axes5,'Amplitude','fontweight','bold');
grid(handles.axes5);
% UIWAIT makes Equalizer wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Equalizer_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 slider movement.
function slider31_Callback(hObject, eventdata, handles)
% hObject handle to slider31 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider31_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider31 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on slider movement.
function slider62_Callback(hObject, eventdata, handles)
% hObject handle to slider62 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider62_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider62 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
⛄ 运行结果
⛄ 参考文献
[1] 李益华. MATLAB辅助现代工程数字信号处理(第2版). 西安:西安电子科技大学出版社,2010
[2] 雷学堂,徐火希. 基于MATLAB的语音滤波实验设计.黄冈师范学院物电系,2007
[3] 赵淑敏. 基于MATLAB实现对语音信号频谱分析. 兰州交通大学电子与信息工程学院,2010
[4] 申鹏. 语音信号的滤波处理及时频域分析. 湖南工业大学计算机与通信学院,2010
[5] 陈亚勇. MATLAB信号处理详解. 北京:人民邮电出版社,2002