showdtcorr.m

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

M
24
字号
%	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=1;
t=[-6:dt:6]';r1=1; r2=fix(length(t)/dt+0.5);npts=length(t)/8;
x=[zeros(1,6),0,1,2,3,zeros(1,3)]';rx=4
subplot(311), stem(t(r1:r2),x(r1:r2),'.'), ylabel('x[k]')
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),stem(t(r1:r2),y,'.'), ylabel('x[m+k]')
   value=sum(x.*y)/rx;
   corrfn(fix(r2/2)+1+t0)=value;hlim=fix(r2/2)+1+t0;axlim=2*rx+1;
%   subplot(313), stem(t(r1:hlim),corrfn(r1:hlim),'.')
   subplot(313),stem (t(t>=0),corrfn(t>=0),'.'),axis([-axlim,axlim,0,max(corrfn)+1]), ylabel('Rx[m]')
   pause%(0.1)
end

⌨️ 快捷键说明

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