How to store corrcoef values?

조회 수: 2 (최근 30일)
Cside
Cside 2020년 2월 14일
댓글: Cside 2020년 2월 14일
Hello, I currently have a script and would like to store the respective r and p values in a matrix. I tried with A(n) = R after the last line but it does not work. Does anyone know what I should code for? Thanks!
for n = 1:10
pfc =A(combined(n,1),:);
fef = B(combined(n,2),:);
%rmb to cut to length
zpfc = zscore(pfc);
zfef = zscore(fef);
[R,P] == corrcoef (zpfc,zfef)); %%how to store the 10 answers from the for loop
end

답변 (1개)

Bhaskar R
Bhaskar R 2020년 2월 14일
편집: Bhaskar R 2020년 2월 14일
If the size of the corrcoef is consistent through out the loop
% row = should write the rows of the corrcoef result
% col = should write the columns of the corrcoef result
R = zeros(row, col, 10); % initiate zeroes mutli dimensional array to store result
P = zeros(row, col, 10);
for n = 1:10
pfc =A(combined(n,1),:);
fef = B(combined(n,2),:);
%rmb to cut to length
zpfc = zscore(pfc);
zfef = zscore(fef);
[R(:, :,n),P(:,:, n)] = corrcoef (zpfc,zfef)); %%how to store the 10 answers from the for loop
end
To access data of R and P
R(:,:, 1) % for n =1 data
For more details
  댓글 수: 1
Cside
Cside 2020년 2월 14일
is there a way to store it in a 2dimensional matrix instead? Would like to see the results at a glance

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

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by