ip_07_12.m
来自「现代通信系统(matlab版) 书中的matlab源代码」· M 代码 · 共 41 行
M
41 行
% MATLAB script for Illustrative Problem 12, Chapter 7.
clear
echo on
alpha=0.4;
T=1/4800;
t=[-3*T:1.001*T/100:3*T];
x=sinc(t./T).*(cos(pi*alpha*t./T)./(1-4*alpha^2*t.^2/T^2));
pause % Press any key to see a plot of x(t).
plot(t,x)
y=xcorr(x);
ty=[t-3*T,t(2:length(t))+3*T];
pause % Press any key to see a plot of the autocorrelation of x(t).
plot(ty,y);
d=60; % Early and late advance and delay
ee=0.01; % Precision
e=1; % Step size
n=700; % The incorrect sampling time
while abs(abs(y(n+d))-abs(y(n-d)))>=ee
if abs(y(n+d))-abs(y(n-d))>0
n=n+e;
elseif abs(y(n+d))-abs(y(n-d))<0
n=n-e;
end
echo off ;
end
echo on ;
pause % Press any key to see the corrected sampling time
n
n=500; % Another incorrect sampling time
while abs(abs(y(n+d))-abs(y(n-d)))>=ee
if abs(y(n+d))-abs(y(n-d))>0
n=n+e;
elseif abs(y(n+d))-abs(y(n-d))<0
n=n-e;
end
echo off ;
end
echo on ;
pause % Press any key to see the corrected sampling time
n
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?