co-variance Matrix formation
5 次查看(过去 30 天)
显示 更早的评论
Hi
I have 6 row matrix of size 1x6
I need to calculate the co variance of all the matrices but cov command only taking two matrices as input
I want a co variance matrix of 6x6
Regards
Uzmeed
1 个评论
charles alexander
2020-11-21
{a1n a2n a6n} by {a2 a6} by {1 1}
{1 a2 a1n} {1 1} {1 sigma 36}.
try the matrix above. the last matrix on the right is the matrix you need. the one that ends with sigma 36.
i hope this helps.
回答(1 个)
BhaTTa
2025-8-14,4:39
I understand you want to calculate a 6x6 covariance matrix from 6 row vectors (each of size 1x6). Please refer to the solution below I have assume that you have 6 seperate row vectors:
% Example: If you have 6 row vectors like this:
row1 = [1, 2, 3, 4, 5, 6];
row2 = [2, 3, 4, 5, 6, 7];
row3 = [3, 4, 5, 6, 7, 8];
row4 = [4, 5, 6, 7, 8, 9];
row5 = [5, 6, 7, 8, 9, 10];
row6 = [6, 7, 8, 9, 10, 11];
% Combine them into a 6x6 matrix (each row is one observation)
data_matrix = [row1; row2; row3; row4; row5; row6];
% Calculate 6x6 covariance matrix
cov_matrix = cov(data_matrix);
disp('6x6 Covariance Matrix:');
disp(cov_matrix);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!