showcorr.m

来自「biomedical stuffs...」· M 代码 · 共 23 行

M
23
字号
%	showcorr.m
%	This program is distributed as a supplement to the book
%	"Biomedical Signal Processing and Signal Modeling" by E. N. Bruce,
%	published by Wiley, 2000.  It is provided for educational use only.
%  While every effort has been made to insure its suitability to illustrate
%  principles described in the above book, no specific feature or capability 
%  is implied or guaranteed.
dt=10;
t=[-900:dt:900]'/100;r1=1; r2=2*fix(900/dt)+1;npts=500;
x=stepfun(t,0)-stepfun(t,3);rx=301;
subplot(311), plot(t(r1:r2),x(r1:r2)), ylabel('x(t)')
corrfn=zeros(size(t));lagmax=r2;
for t0 = 0:dt:r2-1
   leftover=fix(r2/2)+1-npts+t0;
   %  y=[zeros(fix(r2/2)-t0,1);x(t0+fix(r2/2)+1:t0+fix(r2/2)+npts+t0);zeros(leftover,1)];
   y=[zeros(fix(r2/2)-t0,1);x(fix(r2/2)+1:r2);zeros(t0,1)];
   subplot(312),plot(t(r1:r2),y), ylabel('x(t+s)')
   value=sum(x.*y)/rx+0.01;
   corrfn(fix(r2/2)+1+t0)=value;hlim=fix(r2/2)+1+t0;axlim=10;
   subplot(313), plot(t(t>=0),corrfn(t>=0),'.'),axis([-axlim,axlim,0.01,2*max(corrfn)]), ylabel('Rx(s)')
   pause%(0.1)
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?