corrcoef - vectors of different lengths

23 Ansichten (letzte 30 Tage)
Richard
Richard am 2 Apr. 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?

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 2 Apr. 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 Kommentare
Richard
Richard am 2 Apr. 2012
with the first method mentioned, does this basically just make data1 into 24 points instead of 12?
Andrei Bobrov
Andrei Bobrov am 2 Apr. 2012
yes

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by