📄 raise_cosine_filter.m
字号:
% Parameters.
Delay = 3;
DataL = 20;
R = .5;
Fs = 8;
Fd = 1;
PropD = 0;
% Generate random data.
x = randsrc(DataL, 1, [],1245); %建立20行1列的由1,-1随机组成的矩阵
% at time 0, 1/Fd, 2/Fd, ...
tx = [PropD: PropD + DataL - 1] / Fd; %从0到0+20-1(就是19)的1行20列的矩阵
% Plot data.
figure(1),stem(tx, x, 'kx'); %画图
% Set axes and labels.
axis([0 30 -1.6 1.6]); %axis([xmin xmax ymin ymax])
xlabel('Time');
ylabel('Amplitude');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Design filter.
[yf, tf] = rcosine(Fd, Fs, 'fir', R, Delay);
% Upsample and filter.
[yo, to] = rcosflt(x, Fd, Fs, 'filter', yf); %用升余弦滤波器进行滤波
% Plot data.
figure(2),stem(tx, x, 'kx'); hold on;
% Plot filtered data.
plot(to, yo, 'b-'); hold off;
% Set axes and labels.
axis([0 30 -1.6 1.6]); xlabel('Time'); ylabel('Amplitude');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Correct for propagation delay
PropD = Delay * Fd;
% at time 0, 1/Fd, 2/Fd, ...
tx = [PropD: PropD + DataL - 1]/ Fd;
% Plot data.
figure(3),stem(tx, x, 'kx'); hold on;
% Plot filtered data.
plot(to, yo, 'b-'); hold off;
% Set axes and labels.
axis([0 30 -1.6 1.6]); xlabel('Time'); ylabel('Amplitude'); %主要在说延时的问题
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Design filter.
[yg, tg] = rcosine(Fd, Fs, 'fir', .2, Delay);
% Filter data.
[yo1, to1] = rcosflt(x, Fd, Fs, 'normal/fir/filter',yg);
% Plot data.
figure(4),stem(tx, x, 'kx'); hold on;
% Plot filtered data.
plot(to, yo, 'b-',to1, yo1, 'r-'); hold off;
% Set axes and labels.
axis([0 30 -1.6 1.6]); xlabel('Time'); ylabel('Amplitude'); %修改滚降系数所产生的不同效果的比较。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Design square root filter.
[ys, ts] = rcosine(Fd, Fs, 'fir/sqrt', R, Delay);
% Filter at the transmitter.
[yc, tc] = rcosflt(x, Fd, Fs, 'filter', ys);
% Plot data
figure(5),stem(tx, x, 'kx'); hold on;
% Plot filtered data.
plot(tc, yc, 'm-'); hold off;
% Set axes and labels.
axis([0 30 -1.6 1.6]); xlabel('Time'); ylabel('Amplitude'); %方根升余弦滤波的结果
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Filter at the receiver.
[yr, tr] = rcosflt(yc, Fd, Fs, 'filter/Fs', ys);
% Adjust for propagation delay.
tcc = tc + Delay .* Fd; txx = tx + Delay .* Fd;
% Plot data.
figure(6),stem(txx, x, 'kx'); hold on;
% Plot filtered data.
plot(tcc, yc, 'm-',tr, yr, 'b-'); hold off;
% Set axes and labels.
axis([0 30 -1.6 1.6]); xlabel('Time'); ylabel('Amplitude');%接受端滤波
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Design and filter.
[yo2, to2] = rcosflt(x, Fd, Fs, 'normal/fir', R, Delay);
% Plot data.
figure(7),stem(tx, x, 'kx'); hold on;
% Plot filtered data.
plot(to2, yo2, 'b-'); hold off;
% Set axes and labels.
axis([0 30 -1.6 1.6]); xlabel('Time'); ylabel('Amplitude'); %快速滤波
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -