how to find correlation coefficient ?

hello, I have a mat file, which has two columns. file attached.
I want to find a correlation coefficient between these two columns.and p-value also. and also want Plot the Pearson's linear correlation coefficients between these two.

 Respuesta aceptada

Muhammad Usman Saleem
Muhammad Usman Saleem el 11 de Mzo. de 2016

1 voto

4 comentarios

pruth
pruth el 14 de Mzo. de 2016
A= a(:,2);
>> B = a(:,3);
>> [R,P] = corrcoef(A,B)
R =
NaN NaN
NaN NaN
P =
NaN NaN
NaN NaN
pruth
pruth el 14 de Mzo. de 2016
why I m getting nan values?
Muhammad Usman Saleem
Muhammad Usman Saleem el 16 de Mzo. de 2016
Editada: Muhammad Usman Saleem el 16 de Mzo. de 2016
because you have not define a variable before
See this
a=[1 2 3;4 5 6] % creating a matrix
a =
1 2 3
4 5 6
A= a(:,2); % means all rows with second column of a matrix
B = a(:,3); % means all rows with third column of matrix
[R,P] = corrcoef(A,B) %cross correlation
R = % 1 showing good correl
1 1
1 1
P = %depends upon your data set NaN means no corr
1 NaN
NaN 1
hope this will be fine.
pruth
pruth el 17 de Mzo. de 2016
thanks man...

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Descriptive Statistics and Insights en Centro de ayuda y File Exchange.

Preguntada:

el 11 de Mzo. de 2016

Comentada:

el 17 de Mzo. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by