Use of Correlation function( corr)

26 visualizaciones (últimos 30 días)
Abhivyakti
Abhivyakti el 21 de Ag. de 2012
I am new to MATLAB.
I need to test correlation function on a data set in the form of a table(1x9757). When i input this into the correlation function, a new matrix if formes with size 9757x9757. But all the values in it are 'NaN' and in the workspace (where the size and minimum and maximum values of variables is mentioned), in the column of minimum and maximum value a message comes that says, 'Too many elements'.
Could anyone please help me with this. I am stuck on this from a very long time.
Thanks!
  1 comentario
José-Luis
José-Luis el 21 de Ag. de 2012
Editada: José-Luis el 21 de Ag. de 2012
Strange. If your matrix is 1 * 9757 , then there is no correlation to be calculated and the result of corr() should be one. Some data would help to understand the problem.
Cheers!

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 21 de Ag. de 2012
Editada: Star Strider el 21 de Ag. de 2012
I am not sure what you want to do. The reason you are getting a large matrix of NaN values is that you are correlating a vector against itself with a function that calculates the linear correlation of 2 or more vectors. To use corr, you have to have at least a [N x 2] or [2 x N] matrix, or at least 2 vectors of the same size.
If you want to get the autocorrelation of the vector with itself, use the xcorr function in the Signal Processing Toolbox.
  2 comentarios
Abhivyakti
Abhivyakti el 21 de Ag. de 2012
That is helpful, you are right, im a little confused of what i really wish to calculate. Anyhow, could you please tell me where 'corrcoef' is used.
Star Strider
Star Strider el 21 de Ag. de 2012
Editada: Star Strider el 21 de Ag. de 2012
The problem is not with you but with the way different techniques have been named over the years. There are many different functions and measures with quite similar names and interpretations. You have already discovered autocorrelation and cross-correlation.
The correlation coefficient is one of a number of measures used to characterize the linear relationship between two (or more) sets of data. I refer you to a good statistics textbook for a discussion of the various measures and statistics and how they are applied.
From the respective documentation for the functions that calculate the correlation coefficient:
RHO = corr(X) returns a p-by-p matrix containing the pairwise linear correlation coefficient between each pair of columns in the n-by-p matrix X.
and:
R = corrcoef(X) returns a matrix R of correlation coefficients calculated from an input matrix X whose rows are observations and whose columns are variables.
The only way to determine the function you need of all those with some relationship to ‘correlation’ is to explore them and experiment with them to find out which one most closely matches your data and what you want to know about it.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by