co-variance Matrix formation

1 visualización (últimos 30 días)
uzmeed
uzmeed el 5 de Abr. de 2019
Respondida: BhaTTa el 14 de Ag. de 2025
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 comentario
charles alexander
charles alexander el 21 de Nov. de 2020
{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.

Iniciar sesión para comentar.

Respuestas (1)

BhaTTa
BhaTTa el 14 de Ag. de 2025
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:');
6x6 Covariance Matrix:
disp(cov_matrix);
3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by