Covariance calculation like excel formula
1 次查看(过去 30 天)
显示 更早的评论
Hi When I calculate covariance in excel it gives me a number but in matlab it gives me a matrix,why is that?and how can I get the covariance amount like excel? thanks
0 个评论
采纳的回答
Pawel Jastrzebski
2018-4-6
编辑:Pawel Jastrzebski
2018-4-18
Given the code:
A = randi([18 22], 20,1)
B = randi([15 25], 20,1)
C = cov(A,B)
This is the outcome that you'll get:
>> C
C =
1.6947 -0.2842
-0.2842 6.8842
The same data in excel produces the following:
So you get the same values. Read up the documentation for covariance. This is why you get a matrix of the results:
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!