matlab - error with cyclic autocorrelation function -
i'm trying code cyclic autocorrelation function in matlab follows:
t=0:(n-1); t=t*te; i_alpha=0; tau=-n2*te:te:n2*te; alpha=-1/2:1/n:1/2; ryy_cl=zeros(length(alpha),length(tau)); alpha=alpha/te ind_tau=0; i_alpha=i_alpha+1; k=tau ind_tau=ind_tau+1; if k>0 % ryy_cl(i_alpha,ind_tau)=1/length(sig_bin_syl_mod(1:end- k))*sum((sig_bin_syl_mod(1:end-k)).*sig_bin_syl_mod(k+1:end)).*exp(1i*2*pi*alpha*t(1+k:length(sig_bin_syl_mod(1:end)))); ryy_cl(i_alpha,ind_tau)=(1/n)*sum((sig_bin_syl_mod(1:end-k)).*sig_bin_syl_mod(k+1:end)).*exp(-1i*2*pi*alpha*t(1:end-k)); else ryy_cl(i_alpha,ind_tau)=(1/n)*sum((sig_bin_syl_mod(1-k:end)).*sig_bin_syl_mod(1:end+k)).*exp(-1i*2*pi*alpha*t(1-k:end)); end end end
i'm getting errors, , doesn't show expecting. according below formulae, how can fix it?
the code provided incomplete, difficult confidently reproduce error. in particular, haven't defined signal (sig_bin_syl_mod), sampling increment (te), or signal length (n).
i different errors depending on how choose te. simplest thing choose te = 1. isn't realistic. 1-mhz sampling rate have te = 1.0e-6.
when te not integer, can see 1 problem tau not integer, yet assigning k tau, using k index.
so code has basic problems.
now i'm going answer question directly. rewrite code, breaking product above separate steps can debug more easily.
first, don't try ca tau , alpha in 1 shot. focus on getting function correct single cycle frequency alpha , tau. i've put quite few helpful posts on how on cyclostationary.wordpress.com.
second, put corrected single-alpha code in loop. try make efficient.
by way, efficient alternate way estimate cyclic autocorrelation first construct cyclic periodogram (see website) , inverse fourier transform it. harnesses power of fft.
finally, link quora discusses different "cyclic autocorrelation". trying cyclostationary signal processing, link deals dft/fft , circular shifts thereof. see website definition , properties of cyclic autocorrelation of interest you.
chad
Comments
Post a Comment