Correlation between two vectors

97 visualizaciones (últimos 30 días)
Enrica Brunetti
Enrica Brunetti el 1 de Jul. de 2019
Editada: Adam Danz el 15 de Jul. de 2019
How to show the correlation between two vectors? I know I can use the function 'xcorr', but is there a function that shows graphically this correlation?

Respuesta aceptada

Adam Danz
Adam Danz el 1 de Jul. de 2019
Editada: Adam Danz el 15 de Jul. de 2019
Directly from matlab documentation,
n = 0:15;
x = 0.84.^n;
y = circshift(x,5);
[c,lags] = xcorr(x,y);
stem(lags,c)
xlabel('lag')
ylabel('r')
or more simply,
plot(lags, c, '-o')
190715 134831-Figure 1.jpg
This shows a maximum correlation at lag -5 which makes sense since we circularly shifted the data by 5 units.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by