How do I correlate columns
古いコメントを表示
I have 2400 x 1015 matrix. I would like to correlate column 1 with column 926. I would then like to correlate column 1 with 927 and so on until I correlate column 1 with column 1015.
I would then like to print the result of each correlation in row 1, in a new file.
Thanks
1 件のコメント
Jonathan Campelli
2015 年 4 月 14 日
I've made a program that's computing each correlation by the formula, which is returning totally different results from my previous code. Just updating you that I'll post the correct code within the next couple hours, in case you have need of it still. "corrcoeff" was yielding different results than those you asked for. Coming soon...
Jonathan Campelli
採用された回答
その他の回答 (2 件)
Chad Greene
2015 年 4 月 13 日
How's this?
m = rand(2400,1015);
c = corrcoef(m(:,[1 926:1015]));
imagesc(c)
cb = colorbar;
ylabel(cb,'correlation coefficient')
4 件のコメント
Kris
2015 年 4 月 13 日
Jonathan Campelli
2015 年 4 月 13 日
Hello, Kris,
What operation are intending to indicate by the word "correlate"? I may be unfamiliar with the application, and thereby having trouble understanding.
Best,
Jonathan Campelli
Kris
2015 年 4 月 13 日
Jonathan Campelli
2015 年 4 月 13 日
Alright, cooking up some code...
Chad Greene
2015 年 4 月 13 日
The rand function was only to generate random data to play with.
I don't see how you'll get a 925 x 90 correlation matrix. Here I'll make up some data, but set column 1 to sine wave, then columns 926 to the end will have an increasingly high sine wave to random noise ratio. So correlation increases from columns 926 to 1015, as is evident in the top row of subplot 3:
% Some random data:
m = rand(2400,1015);
% The first column is sine function:
m(:,1) = sind(1:2400);
% Force correlation to come increasingly positive
% from cols 926 to 1015,
mag = 0;
for k = 926:1015
m(:,k) = m(:,k) + mag*sind(1:2400)';
mag = mag+.01;
end
subplot(131)
imagesc(m)
title 'full dataset'
subplot(132)
imagesc(corrcoef(m))
title 'correlation all data'
caxis([-1 1])
subplot(133)
c = corrcoef(m(:,[1 926:1015]));
imagesc(c)
title 'correlation of cols 1, 926:1015'
caxis([-1 1])
rgbmap('red','white','blue')

カテゴリ
ヘルプ センター および File Exchange で Descriptive Statistics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
