corrcoef - vectors of different lengths

23 ビュー (過去 30 日間)
Richard
Richard 2012 年 4 月 2 日
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?
Andrei Bobrov
Andrei Bobrov 2012 年 4 月 2 日
yes

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by