how to make a covarinace matrix using data from excel?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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!!
0 Kommentare
Antworten (1)
Bjorn Gustavsson
am 16 Feb. 2021
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 Kommentare
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!