matlab实现低通,带通,高通滤波器

分析https://blog.csdn.net/flypassion/article/details/82082543
基于fdatool的低通滤波器的设计
在MATLAB命令行执行fdatool命令,弹出滤波器设计交互窗口,根据自己的需求设计符合自己要求的滤波器,这是我设计的低通滤波器见下图
需要注意的是通过设计Fpass和Fstop确定了滤波器的带宽,同时参数设计的越接近理论滤波器的性能,滤波器的阶数越多,计算量越大,所以需要优化滤波器这两个参数,在保证性能的同时确保阶数越小(计算量越小)

代码 如下

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	%------------------------------------------------------------------------------------%
	%************************************** Filter **************************************%
	%------------------------------------------------------------------------------------%
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	%   Date:2018.8.25
	%   Author:flypassion
	%   Version:1.0
	clear all
	close all
	clc
	%% Parameter Interface
	Frequence0          = 60;        %单位:Hz    
	Frequence1          = 130;       %单位:Hz
	Frequence2          = 1e3;       %单位:Hz
	SampleFre           = 4e3;       %单位:Hz
	SampleLen           = SampleFre; %采样点数
	%% Main
	%-------------------产生三路信号
	t = 0:1/SampleLen:1/SampleFre*(SampleLen-1);
	SignalData0 = sin(2*pi*Frequence0*t);
	SignalData1 = sin(2*pi*Frequence1*t);
	SignalData2 = sin(2*pi*Frequence2*t);
	SignalData3 = SignalData0+SignalData1+SignalData2;
	figure;hold on
	plot(t(1:150),SignalData0(1:150),'b')
	plot(t(1:150),SignalData1(1:150),'r')
	plot(t(1:150),SignalData2(1:150),'k')
	hold off
	figure;plot(t(1:150),SignalData3(1:150))
	title('三路信号求和')
	%-------------------频谱分析
	FFT_Data = fft(SignalData3);
	Amplitude = abs(FFT_Data);
	Amplitude = Amplitude/length(Amplitude);
	Amplitude(2:end) = 2*Amplitude(2:end);
	Frequence = (0:(length(Amplitude)/2-1))/length(Amplitude)*SampleFre;
	figure;plot(Frequence,Amplitude(1:length(Frequence)))
	title('三路信号叠加频谱')
	%-------------------低通滤波
	LPF_Coe = load('LPF_60M.mat');
	LPF_Data = filter(LPF_Coe.LPF_60M,1,SignalData3);
	figure;plot(t,LPF_Data)
	title('低通滤波之后的波形')
	%-------------------低通滤波之后频谱分析
	FFT_LPF_Data = fft(LPF_Data);
	Amplitude_LPF = abs(FFT_LPF_Data);
	Amplitude_LPF = Amplitude_LPF/length(Amplitude_LPF);
	Amplitude_LPF(2:end) = 2*Amplitude_LPF(2:end);
	Frequence = (0:(length(Amplitude_LPF)/2-1))/length(Amplitude_LPF)*SampleFre;
	figure;plot(Frequence,Amplitude_LPF(1:length(Frequence)))
	title('低通滤波之后的频谱')
	%-------------------带通滤波
	BPF_Coe = load('BPF_130M.mat');
	BPF_Data = filter(BPF_Coe.BPF_130M,1,SignalData3);
	figure;plot(t,BPF_Data)
	title('带通滤波之后的波形')
	%-------------------带通滤波之后频谱分析
	FFT_BPF_Data = fft(BPF_Data);
	Amplitude_BPF = abs(FFT_BPF_Data);
	Amplitude_BPF = Amplitude_BPF/length(Amplitude_BPF);
	Amplitude_BPF(2:end) = 2*Amplitude_BPF(2:end);
	Frequence = (0:(length(Amplitude_BPF)/2-1))/length(Amplitude_BPF)*SampleFre;
	figure;plot(Frequence,Amplitude_BPF(1:length(Frequence)))
	title('带通滤波之后的频谱')

你可能感兴趣的:(通信)