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!
