# Correlation between multiple columns of table

조회 수: 11 (최근 30일)
Daphne PARLIARI . 2021년 6월 18일
댓글: Daphne PARLIARI . 2021년 6월 18일
Hi guys!
I have a table (see attached) for which I want to calculate corrcoef ([r p]) between multiple columns. Eg. between column 2 and column 6, column 2 and column 7, then column 3 and column 6, column 3 and column 7. The last combination would be column 5 and column 12.
Is there a way to do it a with a loop (or any other way, as a matter of fact) and automatically store the values in a new table so that I don't mix them up?
I'm on Matlab 2019a.

댓글을 달려면 로그인하십시오.

### 답변 (1개)

KSSV 2021년 6월 18일
iwant = zeros(2,2,[]) ;
count = 0 ;
for r = 2:3
for p = 6:7
count = count+1 ;
iwant(:,:,count) = corrcoef(data(:,r),data(:,p)) ;
end
end
iwant(:,:,count+1) = corrcoef(data(:,5),data(:,12)) ;
##### 댓글 수: 3표시 이전 댓글 수: 2숨기기 이전 댓글 수: 2
Daphne PARLIARI 2021년 6월 18일
Actually the attached file is a double that I have produced earlier in the code, it's the outerjoin between two tables.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!