Use of Correlation function( corr)
26 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
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 件のコメント
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!