Nor Faizah
2008-03-13 12:56:02 UTC
Hello,
I'm trying to validate the xcorr function in MATLAB with a
simple signal of a sine function. As from the theoretical
result, the autocorrelation of Asin(wt) will give A^2/2cos
(w*tau).
However, when I computed these command,
%%%%%%%% Input parameters %%%%%%%
SR=1000
T =1/SR
L=1000
TT=(-L:L-1)*T
fs=100
As=1
%%%%%%%% Creating Signal %%%%%%%
signal= As*sin(2*pi*fs*TT)
signal= signal(:);
%%%%%%%%%%%%%%%%% Plotting the created signal
figure(1); plot(TT,signal)
xlabel('Time (s)')
ylabel('Y(t)')
%%%%% Calculating the auto-correlation of the signal %%%%%
[c,lags]=xcorr(signal,'coeff');
figure(2); plot(lags,c);
xlabel('\tau (s)')
ylabel('normalised correlation, R')
The autocorrelation plot (figure(2)) results in a cosine
function multiple with some exponential function (which
tends to zero).It suppose to result in a continuous
periodic function of cosine. So, i'm not sure what is
MATLAB actually doing when determining/plotting an
autocorrelation. Could anyone help me with this?
Many thanks.
I'm trying to validate the xcorr function in MATLAB with a
simple signal of a sine function. As from the theoretical
result, the autocorrelation of Asin(wt) will give A^2/2cos
(w*tau).
However, when I computed these command,
%%%%%%%% Input parameters %%%%%%%
SR=1000
T =1/SR
L=1000
TT=(-L:L-1)*T
fs=100
As=1
%%%%%%%% Creating Signal %%%%%%%
signal= As*sin(2*pi*fs*TT)
signal= signal(:);
%%%%%%%%%%%%%%%%% Plotting the created signal
figure(1); plot(TT,signal)
xlabel('Time (s)')
ylabel('Y(t)')
%%%%% Calculating the auto-correlation of the signal %%%%%
[c,lags]=xcorr(signal,'coeff');
figure(2); plot(lags,c);
xlabel('\tau (s)')
ylabel('normalised correlation, R')
The autocorrelation plot (figure(2)) results in a cosine
function multiple with some exponential function (which
tends to zero).It suppose to result in a continuous
periodic function of cosine. So, i'm not sure what is
MATLAB actually doing when determining/plotting an
autocorrelation. Could anyone help me with this?
Many thanks.