how do i calculate the Correlation coefficients

33 vues (au cours des 30 derniers jours)
neamah al-naffakh
neamah al-naffakh le 12 Août 2016
Commenté : the cyclist le 13 Août 2016
I have dataset that contains the acceleration data of three axes (x, y, and z) , this an example of my data
X Y Z
%1.0195313 0.16088867 -0.26391602
%1.0976563 0.17456055 -0.33447266
%1.2556152 0.24926758 -0.3774414
%1.2314453 0.517334 -0.25732422
%1.0212402 0.5761719 -0.09277344
%1.0727539 0.51000977 0.007324219
%1.1694336 0.32885742 -0.017822266
%1.1247559 0.22924805 -0.10595703
%1.0339355 0.27905273 -0.13623047
%0.8273926 0.24560547 -0.080566406
%0.75097656 0.25390625 -0.018310547
%0.67626953 0.3046875 0.051757813
%0.7282715 0.33764648 0.08911133
%0.8227539 0.34545898 0.08325195
%0.87939453 0.3413086 0.08300781
%1.0527344 0.34326172 0.106933594
%1.1125488 0.32128906 0.10058594
%1.1477051 0.26416016 0.06347656
%1.2807617 0.2680664 0.015136719
%1.2800293 0.2668457 -0.006347656
I have calculated the Correlation coefficients of two axes (x and y) using the corrcoef function as illustrated bellow
R = corrcoef(X_Segments{1},Y_Segments{1})
X_Segments contains data of the first column (X Data) and Y_Segments contains data of the second column (Y Data). However, the output was strange
R =
1.0000 0.3424
0.3424 1.0000
I want to know which value represents the Correlation coefficients between X and Y and is there any solution to get the Correlation coefficients between two axes directly as one value (single output) not as a matrix ?

Réponse acceptée

neamah al-naffakh
neamah al-naffakh le 13 Août 2016
Modifié(e) : neamah al-naffakh le 13 Août 2016
Hi guys, thanks for your answer howeover, the correct function is corr
CorrcoeffXY{nn,1} = corr(X_Segments{nn},Y_Segments{nn});
and the output will be the Correlation coefficients between X and Y
R = 0.3424
  1 commentaire
the cyclist
the cyclist le 13 Août 2016
Oh, of course. I only tried
corr(rand(5,2))
(which returns a matrix)
and not
corr(rand(5,1),rand(5,1))
(which returns a scalar).
Glad you found something that worked for you.

Connectez-vous pour commenter.

Plus de réponses (1)

the cyclist
the cyclist le 13 Août 2016
The upper-right and lower-left elements are equal, and each one is the correlation you want. The diagonal elements are the trivial correlation of X with itself and Y with itself. Those will always be equal to 1, by construction.
I don't think there is a simple way to get just the single number without first getting the matrix.
  1 commentaire
Image Analyst
Image Analyst le 13 Août 2016
So, (just to be super explicit)
correlationBetweenXandY = R(1,2);
Is that what you want neamah?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by