|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
直接按定义计算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-----------------------------------------------------------------------
- C Routine CORRE1:To estimate the biased cross-correlation function
- C of complex arrays x and y. If y=x,then it is auto-correlation.
- c input 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.
- c output 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
复制代码 |
|