成形滤波器(⼆,利⽤FDATOOL设计成形滤波器)成形滤波器的设计(FDATOOL)
1 滤波器的设计
1.1 成形滤波器的设计
成形滤波器的设计推荐⽤FDATOOL,⽽不建议使⽤函数。
Response Type:Raised-cosine
Filter order:指定滤波器的阶数
Fs:信号的采样频率
Fc:截⽌频率,其值为码速率RB的⼀半。
Rolloff:滚降系数,⼀般选择0.35。
Normal:升余弦滤波器。
square root:根升余弦滤波器。
function Hd = Shaping_filter
generated%SHAPING_FILTER Returns a discrete-time filter object.
% MATLAB Code
% Generated by MATLAB(R)9.5and DSP System Toolbox 9.7.
% Generated on:13-Dec-202112:17:17
% FIR Window Raised-cosine filter designed using the FIRRCOS function.
% All frequency values are in MHz.
Fs =100;% Sampling Frequency
N =200;% Order
Fc =0.5;% Cutoff Frequency
TM ='Rolloff';% Transition Mode
R =0.35;% Rolloff
DT ='Normal';% Design Type
Beta =0.5;% Window Parameter
% Create the window vector for the design algorithm.
win =kaiser(N+1, Beta);
% Calculate the coefficients using the FIR1 function.
b =firrcos(N, Fc/(Fs/2), R,2, TM, DT,[], win);
Hd = dfilt.dffir(b);
%[EOF]
1.2 低通滤波器的设计
对于基带信号s(t)⽽已,信号的带宽等于码速率RB。现在将基带信号进⾏调制和解调(没有加成形滤波器),得到的表达式为
s(t)cos(2pi fc t)cos(2pi fc t)。从表达式可以看出,为了恢复基带信号,需要滤掉2fc分量。那么如何设计该低通滤波器呢。利⽤matlab的fdatool⼯具。如下图所⽰,
通带频率Fpass:⼀般为码速率RB,为了留点余量,稍微⼤于码速率。RB=1MHz。
截⽌频率Fstop:为2fc-RB,同时也要留点余量。
function Hd = low_pass
%LOW_PASS Returns a discrete-time filter object.
% MATLAB Code
% Generated by MATLAB(R)9.5and DSP System Toolbox 9.7.
% Generated on:13-Dec-202112:20:45
% Equiripple Lowpass filter designed using the FIRPM function.
% All frequency values are in MHz.
Fs =100;% Sampling Frequency
N =50;% Order
Fpass =2;% Passband Frequency
Fstop =18;% Stopband Frequency
Wpass =1;% Passband Weight
Wstop =1;% Stopband Weight
dens =20;% Density Factor
% Calculate the coefficients using the FIRPM function.
b =firpm(N,[0 Fpass Fstop Fs/2]/(Fs/2),[1100],[Wpass Wstop],...
{dens});
Hd = dfilt.dffir(b);
%[EOF]
2 例程
2.1 原代码
%%%%%%%%%%%%%%%%%%成形滤波器的设计与应⽤%%%%%%%%%%%%%%%%%%%%%% %%%%仿真步骤
%1、产⽣基带信号-112、成形滤波器的设计
%3、对基带信号成形,画出信号波形4、成形滤波后的信号进⾏BPSK调制
%5、相⼲解调6、对解调后的信号进⾏低通滤波、成形滤波(可选)
%7、抽样判决
clc;
clear all;
close all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%参数设置%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N=20;%码元个数
fc=10e6;%载波信号频率
Fs =10*fc;%采样频率
RB=1e6;%码速率
count=Fs/RB;%每个码元的采样点数
n=N*count;%总的采样点数
ts=1/Fs;%最⼩采样间隔
Ts=1/Fs*count;%码元周期
t1=(1:N)*Ts;%码元持续时间
t2=(1:n)*ts;%总的持续时间
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%产⽣基带信号%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=randi([01],1,N)*2-1;%产⽣双极性序列1-1
figure(1);
subplot(211);
stem(t1,x);grid on;
ylim([-1.21.2]);
%将x的值插⼊到xt中,每count个插⼀个
for p=1:N
xt(((p-1)*count+1):( p*count))=x(p);
end
subplot(212);
plot(t2,xt);grid on;
ylim([-1.21.2]);
title('基带信号时域波形');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%成型滤波的产⽣%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%成形滤波器的设计推荐⽤FDATOOL,⽽不建议使⽤函数。
% Response Type:Raised-cosine
% Filter order:指定滤波器的阶数
% Fs:信号的采样频率
% Fc:截⽌频率,其值为码速率RB的⼀半。
% Rolloff:滚降系数,⼀般选择0.35。
% Normal:升余弦滤波器。
% square root:根升余弦滤波器。
%SHAPING_FILTER Returns a discrete-time filter object.
% MATLAB Code
% Generated by MATLAB(R)9.5and DSP System Toolbox 9.7.
% Generated on:13-Dec-202112:17:17
% FIR Window Raised-cosine filter designed using the FIRRCOS function.
% All frequency values are in MHz.
Fs =100;% Sampling Frequency
N =200;% Order
Fc =0.5;% Cutoff Frequency
TM ='Rolloff';% Transition Mode
R =0.35;% Rolloff
DT ='Normal';% Design Type
Beta =0.5;% Window Parameter
% Create the window vector for the design algorithm.
win =kaiser(N+1, Beta);
% Calculate the coefficients using the FIR1 function.
yf =firrcos(N, Fc/(Fs/2), R,2, TM, DT,[], win);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %对基带信号成型,画出信号波形%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% y1=conv(yf,xt);
y1=y1((length(yf)-1)/2+1:end-(length(yf)-1)/2);%去掉滤波器的延时
figure(3);
plot(t2,y1); grid on;
legend('基带信号成形滤波后的信号时域波形');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % BPSK调制%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% y_carry=cos(2*pi*fc*t2);
y_bpsk=y1.*y_carry;%调制
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %相⼲解调%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% y_jietiao=y_bpsk.*y_carry;%相⼲解调
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %低通滤波%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %LOW_PASS Returns a discrete-time filter object.
% MATLAB Code
% Generated by MATLAB(R)9.5and DSP System Toolbox 9.7.
% Generated on:13-Dec-202112:20:45
% Equiripple Lowpass filter designed using the FIRPM function.
% All frequency values are in MHz.
Fs =100;% Sampling Frequency
N =50;% Order
Fpass =2;% Passband Frequency
Fstop =18;% Stopband Frequency
Wpass =1;% Passband Weight
Wstop =1;% Stopband Weight
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论