1
function [sm,cwp]=cspect(nlags,ntp,wtype,x,y,wpar)
2
//<sm,cwp>=cspect(nlags,ntp,wtype,x,y,wpar)
3
//Spectral estimation using the modified periodogram method.
4
//Cross-spectral estimate of x and y is calculated when both
5
//x and y are given. Auto-spectral estimate of x is calculated
7
// x :data if vector, amount of input data if scalar
8
// y :data if vector, amount of input data if scalar
9
// nlags :number of correlation lags (pos. integer)
10
// ntp :number of transform points (pos. integer)
11
// wtype :window type ('re','tr','hm','hn','kr','ch')
12
// wpar :optional window parameters
13
// : for wtype='kr', wpar>0
14
// : for wtype='ch', 0<wpar(1)<.5, wpar(2)>0
15
// sm :power spectral estimate in the interval [0,1]
16
// cwp :calculated value of unspecified Chebyshev
20
//author: C. Bunks date: 16 Sept 1988
29
w=window(wtype,2*nlags-1);
33
w=window(wtype,2*nlags-1,wpar);
34
else if wtype=='ch' then,
36
[w,cwp]=window(wtype,2*nlags-1,wpar);
39
w=window(wtype,2*nlags-1);
43
[w,cwp]=window(wtype,2*nlags-1,wpar);
48
//estimate correlations
50
if maxi(size(x))==1 then,
51
nsects=int(x/(3*nlags));
56
xk=getx(xlen,1+(k-1)*xlen);
57
yk=gety(xlen,1+(k-1)*xlen);
58
ss=corr('update',xk,yk,ss);
61
re=[re(nlags:-1:1) re(2:nlags)];
64
xk=getx(xlen,1+(k-1)*xlen);
65
ss=corr('update',xk,ss);
68
re=[re(nlags:-1:1) re(2:nlags)];
72
[re,me]=corr(x,y,nlags);
73
re=[re(nlags:-1:1) re(2:nlags)];
75
[re,me]=corr(x,nlags);
76
re=[re(nlags:-1:1) re(2:nlags)];
80
//window correlation estimate
84
//fourier transform to obtain spectral estimate
86
wree=[wre 0*ones(1,ntp-2*nlags+1)];