VibInfo 发表于 2006-8-6 07:33

直接按定义计算 的互相关函数

直接按定义计算x(n),y(n)的互相关函数若rxy(n),若y(n)=x(n)则求出的是自相关,x,y,r为复序列

主程序:
C----------------------------------------------------------------------
C main program HCORRE1:To test subroutine CORRE1
C To compute the correlation of two complex sequences
c To link subroutine CORRE1
C----------------------------------------------------------------------
      complex x(0:7),r(0:7)
      data n/8/,lag/5/
      do 10 i=0,7
10      x(i)=float(i+1)
      call corre1(x,x,r,n,lag,Ierror)
      if(ierror.ne.0)stop
      write(*,*)'   Ierror=',Ierror
      do 20 i=0,lag-1
         write(*,*)i,r(i)
20      continue
      stop
      end

子程序:
      subroutine corre1(x,y,r,n,lag,ierror)
C-----------------------------------------------------------------------
CRoutine CORRE1:To estimate the biased cross-correlation function
Cof complex arrays x and y. If y=x,then it is auto-correlation.
cinput parameters:
c   x:n dimensioned complex array.
c   y:n dimensioned complex array.
c   n:the dimension of x and y.
c   lag:the requested point numbers of correlation.
coutput parameters:
c   r:lag dimensioned complex array, the correlation function is
c         stored in r(0) to r(lag-1).
c                                    in Chapter 1 and 11
C-----------------------------------------------------------------------
      complex x(0:n-1),y(0:n-1),r(0:lag-1)
      Ierror=1
      if(lag.gt.n) return
      Ierror=0
      do 30 k=0,lag-1
         m=n-1-k
         r(k)=0.0
         do 10 j=0,m
            r(k)=r(k)+y(j+k)*conjg(x(j))
10         continue
         r(k)=r(k)/float(n)
30   continue
       return
       end
页: [1]
查看完整版本: 直接按定义计算 的互相关函数