test2.m
来自「cdma 系统级仿真」· M 代码 · 共 48 行
M
48 行
clc;%清除命令窗口
clear all;%清除工作空间workspace,以释放内存
close all;
% Parameters.
Delay = 3; DataL = 20; R = .5; Fs = 8; Fd = 1; PropD = 0;
% Generate random data.
x = randsrc(DataL, 1, [], 1245);
% at time 0, 1/Fd, 2/Fd, ...
tx = [PropD: PropD + DataL - 1] ./ Fd;
% Plot data.
stem(tx, x, 'kx');
% Set axes and labels.
axis([0 30 -1.6 1.6]); 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.
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.
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.
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');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?