From: yoann06 on
Dear all,
I am a new user of matlab. and as I dont have acces to all the tool
boxes, I would like to write my own autocorrelation function.
I have a discrete time series, and I would like to calculate the
autocorrelation between 2 values of this series with a time lag of 1.
this to enhance seasonal variations.
I have very basic knowledge in programing, so if anyone have already
write this kind of script, and would like to share it, it will be very
appriciated. all kind of help or obviously welcome,
thank you in advance,
best regards
Yoann
From: Wayne King on
yoann06 <ydrocourt(a)gmail.com> wrote in message <440eb778-6754-4ea1-8183-144bfeac7ccf(a)e5g2000yqn.googlegroups.com>...
> Dear all,
> I am a new user of matlab. and as I dont have acces to all the tool
> boxes, I would like to write my own autocorrelation function.
> I have a discrete time series, and I would like to calculate the
> autocorrelation between 2 values of this series with a time lag of 1.
> this to enhance seasonal variations.
> I have very basic knowledge in programing, so if anyone have already
> write this kind of script, and would like to share it, it will be very
> appriciated. all kind of help or obviously welcome,
> thank you in advance,
> best regards
> Yoann

You say you don't have access to all toolboxes. Do you have the Signal Processing Toolbox?

Wayne
From: yoann06 on
On 23 June, 13:40, "Wayne King" <wmkin...(a)gmail.com> wrote:
> yoann06 <ydroco...(a)gmail.com> wrote in message <440eb778-6754-4ea1-8183-144bfeac7...(a)e5g2000yqn.googlegroups.com>...
> > Dear all,
> > I am a new user of matlab. and as I dont have acces to all the tool
> > boxes, I would like to write my own autocorrelation function.
> > I have a discrete time series, and I would like to calculate the
> > autocorrelation between 2 values of this series with a time lag of 1.
> > this to enhance seasonal variations.
> > I have very basic knowledge in programing, so if anyone have already
> > write this kind of script, and would like to share it, it will be very
> > appriciated. all kind of help or obviously welcome,
> > thank you in advance,
> > best regards
> > Yoann
>
> You say you don't have access to all toolboxes. Do you have the Signal Processing Toolbox?
>
> Wayne

Hi Wayne,
No unfortunately I don t
From: Wayne King on
yoann06 <ydrocourt(a)gmail.com> wrote in message <dc1a1d27-6898-440c-b58a-44a6a76c3271(a)d37g2000yqm.googlegroups.com>...
> On 23 June, 13:40, "Wayne King" <wmkin...(a)gmail.com> wrote:
> > yoann06 <ydroco...(a)gmail.com> wrote in message <440eb778-6754-4ea1-8183-144bfeac7...(a)e5g2000yqn.googlegroups.com>...
> > > Dear all,
> > > I am a new user of matlab. and as I dont have acces to all the tool
> > > boxes, I would like to write my own autocorrelation function.
> > > I have a discrete time series, and I would like to calculate the
> > > autocorrelation between 2 values of this series with a time lag of 1.
> > > this to enhance seasonal variations.
> > > I have very basic knowledge in programing, so if anyone have already
> > > write this kind of script, and would like to share it, it will be very
> > > appriciated. all kind of help or obviously welcome,
> > > thank you in advance,
> > > best regards
> > > Yoann
> >
> > You say you don't have access to all toolboxes. Do you have the Signal Processing Toolbox?
> >
> > Wayne
>
> Hi Wayne,
> No unfortunately I don t

Hi Yoann:

% x is your signal
% numLags is the number of lags you want, e.g. 50
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

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
From: yoann06 on
On 23 June, 14:25, "Wayne King" <wmkin...(a)gmail.com> wrote:
> yoann06 <ydroco...(a)gmail.com> wrote in message <dc1a1d27-6898-440c-b58a-44a6a76c3...(a)d37g2000yqm.googlegroups.com>...
> > On 23 June, 13:40, "Wayne King" <wmkin...(a)gmail.com> wrote:
> > > yoann06 <ydroco...(a)gmail.com> wrote in message <440eb778-6754-4ea1-8183-144bfeac7...(a)e5g2000yqn.googlegroups.com>...
> > > > Dear all,
> > > > I am a new user of matlab. and as I dont have acces to all the tool
> > > > boxes, I would like to write my own autocorrelation function.
> > > > I have a discrete time series, and I would like to calculate the
> > > > autocorrelation between 2 values of this series with a time lag of 1.
> > > > this to enhance seasonal variations.
> > > > I have very basic knowledge in programing, so if anyone have already
> > > > write this kind of script, and would like to share it, it will be very
> > > > appriciated. all kind of help or obviously welcome,
> > > > thank you in advance,
> > > > best regards
> > > > Yoann
>
> > > You say you don't have access to all toolboxes. Do you have the Signal Processing Toolbox?
>
> > > Wayne
>
> > Hi Wayne,
> > No unfortunately I don t
>
> Hi Yoann:
>
> % x is your signal
> % numLags is the number of lags you want, e.g. 50
> 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
>
> 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- Hide quoted text -
>
> - Show quoted text -

Yes thank you,
it seems to give the right autoccorrelation pic.
very nice
all the best
Yoann