How to type an auto-correlation function in MATLAB

3 visualizaciones (últimos 30 días)
Jonathan Hollingsworth
Jonathan Hollingsworth el 15 de Abr. de 2021
Editada: Chunru el 15 de Abr. de 2021
I am trying to type the following equation into MATLAB as a basis to calculate autocorrelation values. How would I go about writing this equation as a function?
  1 comentario
Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro el 15 de Abr. de 2021
Try Matlab documentation (e.g.https://uk.mathworks.com/help/matlab/ref/xcorr.html). Come back if you have a specific question or something that did not work.

Iniciar sesión para comentar.

Respuesta aceptada

Chunru
Chunru el 15 de Abr. de 2021
Editada: Chunru el 15 de Abr. de 2021
Try the following
N=1000;
x = randn(N+1, 1);
M = 20;
R = zeros(M+1, 1);
for n=0:M
for k=0:N-n
R(n+1) = R(n+1) + x(k+1) * x(k+n+1);
end
R(n+1) = R(n+1) / (N-n+1);
end

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by