corrcoef - vectors of different lengths

23 次查看(过去 30 天)
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?

采纳的回答

Andrei Bobrov
Andrei Bobrov 2012-4-2
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 个评论
Richard
Richard 2012-4-2
with the first method mentioned, does this basically just make data1 into 24 points instead of 12?

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by