Find correlation coefficient of every nth row

1 view (last 30 days)
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.

Accepted Answer

Andrei Bobrov
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)');

More Answers (0)

Community Treasure Hunt

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

Start Hunting!