how to make a covarinace matrix using data from excel?
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Bjorn Gustavsson
2021 年 2 月 16 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!