Use of Correlation function( corr)

조회 수: 26 (최근 30일)
Abhivyakti
Abhivyakti 2012년 8월 21일
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
José-Luis
José-Luis 2012년 8월 21일
편집: José-Luis 2012년 8월 21일
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!

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2012년 8월 21일
편집: Star Strider 2012년 8월 21일
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
Abhivyakti
Abhivyakti 2012년 8월 21일
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 2012년 8월 21일
편집: Star Strider 2012년 8월 21일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by