Home > database >  Correlation Coefficient in MATLAB with variable names
Correlation Coefficient in MATLAB with variable names

Time:11-26

I want to calculate the correlation coefficient between variables in MATLAB. I have a matrix called M, in which each column represents a variable. This is the function I'm using:

A = corrcoef(M,"Rows","complete")

I am getting a table of correlation coefficients, but not the variable names. For instance, I cannot directly see what the 3rd column in A represents - I'd have to go and check M to see the ordering of the variables along the columns.

How do I display the variable names in the correlation table?

Note: I converted M to a table and added variable headers, but the correlation table does not show the variable names.

CodePudding user response:

As @BillBokeey suggested in the comments, a solution is to create a table from the array A, and then add the row and column headers I had previously created for M.

  • Related