For loop for correlation - linear indexing

I have a large dataset (4078x1034) where I need to find the corrcoef, keeping one column (1) constant and testing it with the other columns, starting at column 11.
Matlab tells me this error:
Error using corrcoef (line 114)
Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not supported. Use a row subscript and a variable subscript.
How can i fix this?
A = readtable('train_v1.csv');
e = A{:,1}; %constant column
S = size(A);
K = zeros(1,(S(1,2)-11)); %preparing the output matrix
for i = 11:S(1,2)
tmp = corrcoef(e,A(:,i));
K(i-10) = tmp;
end
disp(K)

 採用された回答

the cyclist
the cyclist 2021 年 9 月 27 日

1 投票

I think you need to use
A{:,i}
instead of
A(:,i)
in the call to corrcoef.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMultidimensional Arrays についてさらに検索

製品

リリース

R2019a

質問済み:

2021 年 9 月 27 日

回答済み:

2021 年 9 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by