From: Luna Moon on 29 Jul 2010 07:58 I don't have the toolbox, how to write my own "autocorr"? Thanks a lot!
From: us on 29 Jul 2010 08:06 On Jul 29, 1:58 pm, Luna Moon <lunamoonm...(a)gmail.com> wrote: > I don't have the toolbox, > > how to write my own "autocorr"? > > Thanks a lot! a hint: http://en.wikipedia.org/wiki/Autocorrelation us
From: Wayne King on 29 Jul 2010 08:11 Luna Moon <lunamoonmoon(a)gmail.com> wrote in message <ff4a396d-d548-4975-ba35-662180d14d78(a)g19g2000yqc.googlegroups.com>... > I don't have the toolbox, > > how to write my own "autocorr"? > > Thanks a lot! Hi Luna, you can do something like this: % x is your signal % numLags is the number of lags you want, e.g. 50,20 etc. x = detrend(x,0); xmagDFT = abs(fft(x)).^2; autocorr = ifft(xmagDFT,'symmetric'); autocorr= autocorr(1:numLags); % normalize the autocorrelation you may or may not want this autocorr = autocorr./autocorr(1); % Example with white noise-- create white noise input and estimate % its autocorrelation sequence reset(RandStream.getDefaultStream); x = randn(512,1); numLags = 50; x = detrend(x,0); xmagDFT = abs(fft(x)).^2; autocorr = ifft(xmagDFT,'symmetric'); autocorr= autocorr(1:numLags); % normalize the autocorrelation autocorr = autocorr./autocorr(1); stem(autocorr); Hope that helps, Wayne
|
Pages: 1 Prev: mnrfit, mnrvalue Next: Attemp to reference field of a non-structure array |