corrcoef - vectors of different lengths

36 visualizaciones (últimos 30 días)
Richard
Richard el 2 de Abr. de 2012
How is it possible to find the correlation between vectors of different lengths? For example:
clear all
time1 = 1 + (365-1).*rand(1,12);
time2 = 1 + (365-1).*rand(1,24);
data1 = 1 + (20-1).*rand(1,12);
data2 = 1 + (20-1).*rand(1,24);
usually I would find the correlation with:
R = corrcoef(data1,data2);
but the vectors need to be the same lengths! How would I achieve this?

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 2 de Abr. de 2012
try use function interp1
eg
data1 = 1 + (20-1).*rand(1,12);
data2 = 1 + (20-1).*rand(1,24);
d2 = interp1(1:numel(data1),data1,linspace(1,numel(data1),numel(data2)));
R = corrcoef(d2,data2)
OR
d2 = data2(1:2:end)
R = corrcoef(data1,d2)
  2 comentarios
Richard
Richard el 2 de Abr. de 2012
with the first method mentioned, does this basically just make data1 into 24 points instead of 12?
Andrei Bobrov
Andrei Bobrov el 2 de Abr. de 2012
yes

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by