Matlab函数:mean
>>X=[1,2,3]
>>mean(X)=2
如果X是一个矩阵,则其均值是一个向量组.mean(X,1)为列向量的均值,mean(X,2)为行向量的均值.
>>X=[1 2 3
4 5 6]
>>mean(X,1)=[2.5,3.5,4.5]
>>mean(X,2)=[2
5]
若要求整个矩阵的均值,则为mean(mean(X)).
>>mean(mean(X))=3.5
也可使用mean2函数:
>>mean2(X)=3.5
协方差矩阵
A=[61.45,55.9,61.95,59,58.14,53.61,55.48,54.21,61.52,54.92];
B=[40.36,39.8,49.2,48,51.5,49.39,51.13,58.06,61,62.35];
C=[8.61,8.91,10.43,13.32,13.48,15.75,18.14,19.95,21.95,23.53];
D=[14.31,14.72,15.28,15.91,14.67,15,15.86,15.16,13.72,12.94];
E=[7.67,7.75,8.15,9.24,10.68,10.58,10.31,10,8.91,8.51];
>> q=[A',B',C',D',E'];
>> w=cov(q)
w =
10.3710 -4.7446 -6.6023 -0.1873 -1.8881
-4.7446 59.1503 38.7606 -3.0743 3.0982
-6.6023 38.7606 28.6966 -2.0199 2.4166
-0.1873 -3.0743 -2.0199 0.8474 0.3936
-1.8881 3.0982 2.4166 0.3936 1.3412
来自网络