滤波器设计基于matlab GUI窗函数法高通+低通+带通带阻FIR滤波器设计含Matlab源码 072期

Posted 紫极神光

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了滤波器设计基于matlab GUI窗函数法高通+低通+带通带阻FIR滤波器设计含Matlab源码 072期相关的知识,希望对你有一定的参考价值。

一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【滤波器设计】基于matlab GUI窗函数法高通+低通+带通带阻滤波器设计【含Matlab源码 072期】

获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

备注:订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);

二、数字滤波器设计简介(附滤波器参数设置说明书)

1 设计原理

1.1 滤波器概念

1.2 数字滤波器的系统函数和差分方程

1.3 数字滤波器结构的表示


1.4 数字滤波器的分类


2.1 IIR滤波器与FIR滤波器的分析比较

2.2 FIR滤波器的原理








3 FIR滤波器的仿真步骤

三、部分源代码

%DSP语音滤波
%常函数法设计低通、高通、带通、带阻滤波器
function varargout = DSP_fiters004(varargin)
% DSP_FITERS004 MATLAB code for DSP_fiters004.fig
%      DSP_FITERS004, by itself, creates a new DSP_FITERS004 or raises the existing
%      singleton*.
%
%      H = DSP_FITERS004 returns the handle to a new DSP_FITERS004 or the handle to
%      the existing singleton*.
%
%      DSP_FITERS004('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in DSP_FITERS004.M with the given input arguments.
%
%      DSP_FITERS004('Property','Value',...) creates a new DSP_FITERS004 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before DSP_fiters004_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to DSP_fiters004_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 DSP_fiters004

% Last Modified by GUIDE v2.5 26-May-2021 19:06:06

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @DSP_fiters004_OpeningFcn, ...
                   'gui_OutputFcn',  @DSP_fiters004_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin1)
    gui_State.gui_Callback = str2func(varargin1);
end

if nargout
    [varargout1:nargout] = gui_mainfcn(gui_State, varargin:);
else
    gui_mainfcn(gui_State, varargin:);
end
% End initialization code - DO NOT EDIT


% --- Executes just before DSP_fiters004 is made visible.
function DSP_fiters004_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 DSP_fiters004 (see VARARGIN)

% Choose default command line output for DSP_fiters004
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes DSP_fiters004 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = DSP_fiters004_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
varargout1 = handles.output;


% --- 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)
y = handles.y;  %带噪语言
%%
% %FIR低通滤波器_等波纹法备选方案
% fp = str2double(get(handles.edit12,'String'));   %通带截止频率
% fs = str2double(get(handles.edit13,'String'));   %阻带截止频率
% At = 100;    %带外衰减系数(dB)
% wave=1;      %带内纹波系数(dB)
% mval=[1 0];  %边界处的幅值
% fedge=[fp fs];
% derta1=1-10^(-wave/20); %δ1的计算
% derta2=10^(-At/20);     %δ2的计算
% dev=[derta1 derta2];    %基本参数δ1与δ2
% Fs=8000;     %FIR采样频率
% %参数计算
% [N,fpts,mag2,wt]=remezord(fedge,mval,dev,Fs);
% %雷米兹交替算法设计最优FIR滤波器
% b=remez(N,fpts,mag2,wt);
% %FIR低通滤波器滤波
% sf1=filter(b,1,y);
% x=sf1;       %信号
% plot(handles.axes5,x);   %绘出随频率变化的振幅
% y1 = fft(x); %对信号进行快速Fourier变换
% mag2 = abs(y1);   %求得Fourier变换后的振幅
%% 凯塞窗滤波
fs = 8000;
hn = handles.hn;
x1 = fftfilt(hn,y);
% filename = 'kaiser.wav';
% audiowrite(filename,x1,fs);
n = length(x1);
f = fs*(0:n/6-1)/n;
t = (0:n-1)/fs;
figure(9)
subplot(5,1,2);plot(t,y(:,1)); %加噪语音信号的时域波形图
xlabel('时间/s');ylabel('振幅/V');
title('加高斯白噪声后语音信号的时域波形'); grid on;
subplot(5,1,3);plot(t,x1(:,1));
xlabel('时间/s');ylabel('振幅/V');
hold on;title('加高斯白噪声的语音信号滤波后的时域波形');  
hold off;grid on;
y_zz = fft(y);  %带噪语音的频谱图
subplot(5,1,4);plot(f,abs(y_zz(1:n/6)));     %加噪语音信号的频谱图
%axis([0, 8000, 0, 0.05])
xlabel('频率/Hz');ylabel('幅度/dBm');
title('加高斯白噪声后语音信号的频域波形');  grid on;
x11=fft(x1,n);
subplot(5,1,5);plot(f,abs(x11(1:n/6)));
xlabel('频率/Hz');ylabel('幅度/dBm');
hold on;title('加高斯白噪声的语音信号经凯塞滤波后的频域波形');  
hold off;grid on;
% sound(x1,fs)
[H,f]=freqz(hn,1);
subplot(5,1,1);plot(f,20*log10(abs(H)/max(abs(H))));
xlabel('归一化频率');ylabel('振幅/dB');
hold on;title('频率响应');  
hold off;grid on;
plot(handles.axes5,t,x1(:,1))

mag2 = abs(x11);  %滤波后的频谱
sf1 = x1;    %滤波后的信号
handles.mag2 = mag2;
handles.sf1 = sf1;
guidata(hObject,handles)


% --- 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)
sf1 = handles.sf1;
fs = handles.edit11;
clear sound
sound(sf1,fs)

% --- 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)
mag2 = handles.mag2;
plot(handles.axes6,mag2(:,1));   %绘出随频率变化的振幅

% --- 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)
y = handles.y;
fs = handles.edit11;
clear sound
sound(y,fs)

% --- 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)
x = handles.x;
fs = handles.edit11;
clear sound
sound(x,fs)

% --- Executes on button press in OpenFile.
function OpenFile_Callback(hObject, eventdata, handles)
% hObject    handle to OpenFile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[file, path] = uigetfile('*.wav';'*.mp3';'*.*',...
                          'File Selector');
if isequal(file, 0) % 如果file的返回值等于0
   disp('User selected Cancel'); 
else
    disp(['User selected ', fullfile(path, file)]); 
    [x,fs] = audioread(fullfile(path, file));
    plot(handles.axes1,x(:,1))
    handles.x = x;
    handles.edit11 = fs;
    guidata(hObject,handles)
end

四、运行结果

五、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 沈再阳.精通MATLAB信号处理[M].清华大学出版社,2015.
[2]高宝建,彭进业,王琳,潘建寿.信号与系统——使用MATLAB分析与实现[M].清华大学出版社,2020.
[3]王文光,魏少明,任欣.信号处理与系统分析的MATLAB实现[M].电子工业出版社,2018.
[4]王怡,涂宇,谭泽涛,吕雅婷.基于Matlab的FIR滤波器设计与仿真[J].电子技术与软件工程. 2020(18)

以上是关于滤波器设计基于matlab GUI窗函数法高通+低通+带通带阻FIR滤波器设计含Matlab源码 072期的主要内容,如果未能解决你的问题,请参考以下文章

滤波器基于matlab GUI高通+低通+带通+带阻FIR滤波器设计含Matlab源码 1346期

滤波器基于matlab GUI高通+低通+带通+带阻FIR滤波器设计含Matlab源码 1345期

语音处理基于matlab GUI语音信号处理与滤波含Matlab源码 1663期

FIR滤波器的Matlab设计(含低通,高通,带通和带阻)

基于窗函数法的FIR数字滤波器实现matlab仿真

求用matlab实现fir滤波器(低通、高通,带通)