?? test2.m
字號:
clc;%清除命令窗口
clear all;%清除工作空間workspace,以釋放內(nèi)存
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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -