设计升余弦滤波器以及方均根版升余弦滤波器并且使用
在matlab中有很多种写法,下面我将展示这些。
缺省
缺省
comm.RaisedCosineTransmitFilter with properties:
Shape: 'Square root'
RolloffFactor: 0.2000
FilterSpanInSymbols: 10
OutputSamplesPerSymbol: 8
Gain: 1
b = rcosdesign(beta,span,sps)
b = rcosdesign(beta,span,sps,shape)
至少提供前三个参数,beta是滚降系数,sps是样本每符号,sps*span+1是设计出的FIR滤波器长度,shape缺省是'sqrt'
多种方法
rcosdesign设计个滤波器,之后upsample,conv,upfirdn,filter之类的来处理(本质是:上采样,线性卷积,下采样,怎么写是你的事情)
comm.RaisedCosineTransmitFilter得到函数句柄(一个函数对象),之后使用这个函数就行了
rcosflt
clear all;
close all;
clc;
nSym = 2048; % Number of input symbols
sps = 4; % Samples per symbol
nSamp = nSym*sps; % Number of samples
mOrder = 4; % mOrder psk
data = randi([0 mOrder-1],nSym,1);
modData = pskmod(data,mOrder,pi/mOrder);
%%%%%%%%%%%方法一
h=rcosdesign(0.2,8,sps,'sqrt');
%上采样倍数建议选择为滤波器的OutputSamplesPerSymbol,即这里的sps。可以理解成,一个是声明滤波器时使用的参数,一个是应用滤波器时指定的参数,应保持一致。
%即,建议下面的OutputSamplesPerSymbol选择为滤波器设计那里的sps
txSig=upfirdn(modData,h,sps);
txSig=txSig(1:end-length(h)+sps);
scatterplot(txSig)
%%%%%%%%%%%方法二
txfilter = comm.RaisedCosineTransmitFilter(...
'RolloffFactor',0.2, ...
'FilterSpanInSymbols',8, ...
'OutputSamplesPerSymbol',sps);
%ans=coeffs(txfilter);
%fvtool(ans.Numerator,'Analysis','impulse');
txSig1 = txfilter(modData);
scatterplot(txSig1)
%%%%%%%%%%%方法三
%rcosflt function: rcosdesign function and either filter or upfirdn functions
%请读者自行补充吧
ans=0;
for i=1:length(txSig)
if abs(txSig(i)-abs(txSig1(i)))<1e-10
ans=ans+1
else
display(txSig(i));
display(txSig1(i));
end
end
ans
结论
txSig和txSig1可以说是一模一样
背景知识补充
upfirdn函数介绍
upfirdn函数的介绍是说,上采样,过FIR滤波器,下采样。数学上就是说:每两个数间补【升采样倍数-1】个零,之后和h线性卷积,之后每【降采样倍数】个数取第一个数出来。
upfirdn函数的一些例子是
输入信号,滤波器,升采样倍数,降采样倍数
>> upfirdn([1,2],[3,4],1) 3 10 8
>> upfirdn([1,2],[3,4],2) 3 4 6 8
>> upfirdn([1,2],[3,4,5],2,1) 3 4 11 8 10
>> upfirdn([1,2],[3,4,5],2,3) 3 8
upfirdn(xn,hn,length) 作用为把xn中的每个值乘以序列hn,然后移位相加,length表示了移位的长度。其中xn、hn的点数分别为N1、N2,输出点数为 N2+(N1-1)×length
这样过后最后输出的点数是N2+(N1-1)×length ,所以最后还需要截断一下使得点变成N1×length
补充:啥是成型滤波器?
成型滤波器 是在发送端将信号经过成形滤波器进行带限,使信号带宽匹配信道带宽。
(如果没有成型滤波。时域上0、1信号是矩形信号,频域得无限宽才能传输,没有这样的信道;而信号带限就会引入码间串扰,会导致接收信号波形失真。所以成型滤波)
参考
https://blog.csdn.net/weixin_44884357/article/details/89488374 一文理解matlab的成型滤波器设计
http://matrix.etseq.urv.es/manuals/matlab/toolbox/comm/rcosflt.html rcosflt文档