Corrcoef error: "cannot compute p-values for complex inputs".

조회 수: 15 (최근 30일)
Mathew Grey
Mathew Grey 2018년 8월 6일
답변: Amal George M 2018년 8월 14일
Hi All,
I am running this code
SR = [GPS.SR' Physio.SR'];
JR = [GPS.JR' Physio.JR'];
JM = [GPS.JM' Physio.JM'];
AG = [GPS.AG' Physio.AG'];
TH = [GPS.TH' Physio.TH'];
AH = [GPS.AH' Physio.AH'];
BP = [GPS.BP' Physio.BP'];
DD = [GPS.DD' Physio.DD'];
CP = [GPS.CP' Physio.CP'];
TB = [GPS.TB' Physio.TB'];
AB = [GPS.AB' Physio.AB'];
ABa = [GPS.ABa' Physio.ABa'];
LR = [GPS.LR' Physio.LR'];
JB = [GPS.JB' Physio.JB'];
JP = [GPS.JP' Physio.JP'];
KR = [GPS.KR' Physio.KR'];
JMe = [GPS.JMe' Physio.JMe'];
WB = [GPS.WB' Physio.WB'];
LW = [GPS.LW' Physio.LW'];
PS = [GPS.PS' Physio.PS'];
KA = [GPS.KA' Physio.KA'];
HA = [GPS.HA' Physio.HA'];
i = {SR, JR, JM, AG, TH, AH, BP, DD, CP, TB, ...
AB, ABa, LR, JB, JP, KR, JMe, WB, LW, PS, ...
KA, HA};
for player = 1 : length(i)
[R, P] = corrcoef(i(:, 4), i(:, 13), 'Rows', 'complete')
end
Where the first part is concatenating from 2 separate structures and putting the data together into individual matrices (each one is 287 x 15). I am then trying to go into each one of 'i' and correlate (r and p-value) the 287 rows of columns 4 and 13 (for now) - but only if the row is complete (does not contain NaNs). However, every time I run it, I get the error: "Cannot compute p-values for complex inputs". Can anyone see what I am doing wrong please? It says the error is in the "[R, P] = corrcoef(i(:, 4), i(:, 13), 'Rows', 'complete')" line of code.
Kind regards, Mat

답변 (1개)

Amal George M
Amal George M 2018년 8월 14일
Hi Mat,
According to my understanding, here "i" is a cell-array and the requirement is to find correlated-coefficients ("corrcoef") between the 4th column and 13th column of each individual matrix in "i".
The error seems to originate from the "for" loop implementation. The variable which is iterated is "player", so using that we can extract the required matrix to a temporary variable and then use the corresponding columns to generate the result. Here is the modified code:
for player = 1 : length(i)
temp = i{player}; % accessing the "player"-th matrix in "i"
[R, P] = corrcoef(temp(:, 4), temp(:, 13), 'Rows', 'complete')
end
Hope this helps.

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by