Find correlation coefficient of every nth row
1 view (last 30 days)
Show older comments
David du Preez
on 13 Apr 2017
Answered: Andrei Bobrov
on 13 Apr 2017
I have two 121x14 matrices. I want to find the correlation coefficient of column 8 in each matrix. So I have made two matrices with only the data that I want to correlate. Using:
UVI_am = CP_ALL_W_am(:,8);
UVI_pm = CP_ALL_W_pm(:,8);
Now I want to correlate every 11 rows and save the correlation coefficient to different output array. I know you can correlate using:
R=corr(UVI_am,UVI_pm);
but how does one limit to every 11 rows and repeat it.
0 Comments
Accepted Answer
Andrei Bobrov
on 13 Apr 2017
UVI_am = reshape(CP_ALL_W_am(:,8),11,[]);
UVI_pm = reshape(CP_ALL_W_pm(:,8),11,[]);
R = arrayfun(@(ii)corr(UVI_am(:,ii),UVI_pm(:,ii)),(1:11)');
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!