how to make a covarinace matrix using data from excel?
Mostrar comentarios más antiguos
Hello!
I am new to MATLAB and need help with making a covariance matrix
I have data in the following format
Date A B C D E
11.02.2021 8,506 8,654 14,396 17,648 7,457
10.02.2021 8,394 8,678 14,263 17,799 7,481
I need to make a 5X5 matrix and store the value in a variable.
Please Help!!
Respuestas (1)
Bjorn Gustavsson
el 16 de Feb. de 2021
0 votos
Just use cov. From the help of the cov-function:
cov Covariance matrix.
cov(X), if X is a vector, returns the variance. For matrices, where
each row is an observation, and each column a variable, cov(X) is the
covariance matrix. DIAG(cov(X)) is a vector of variances for each
column, and SQRT(DIAG(cov(X))) is a vector of standard deviations.
cov(X,Y), where X and Y are matrices with the same number of elements,
is equivalent to cov([X(:) Y(:)]).
So just extract your [ n_obs x 5 ] data from your excell-file and send that matrix to the cov-function.
HTH
2 comentarios
Anurag Kumar Verma
el 16 de Feb. de 2021
Bjorn Gustavsson
el 16 de Feb. de 2021
You're welcome.
Categorías
Más información sobre Data Import from MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!