Borrar filtros
Borrar filtros

plz explain what does this code do..?

3 visualizaciones (últimos 30 días)
praveen singathi
praveen singathi el 20 de Mzo. de 2021
Comentada: praveen singathi el 21 de Mzo. de 2021
[V, D] = eig(cov(M));
[z1 s1] = size(D);
for i=1:1:s1
D1(i)=D(i,i);
end
D2=max(D1(i));
for i=1:1:s1
if D1(i)==D2;
a1 = V(:,i)./sum(V(:,i));
end
end
[z2 s2]=size(ca{1});

Respuesta aceptada

KSSV
KSSV el 20 de Mzo. de 2021
[V, D] = eig(cov(M)); % Calculates the eigenvalues and eigenvectors of covariance of matrix M
[z1 s1] = size(D); % gets the size of diagonal eigenvalue matrix D
for i=1:1:s1
D1(i)=D(i,i); % this loop saves doagonal elements i.e. eigenvalues in D1/
end
% The above can be achieved with D1 = diag(D)
D2=max(D1(i)); % Assigns D1(s1) to D2, this is wrong..should be D2 = max(D1)
for i=1:1:s1 % loop for each eigenvector/ eigenvalue
if D1(i)==D2; % if D1 is equal to maxof D1
a1 = V(:,i)./sum(V(:,i)); % normalize the eigen vectors
end
end
[z2 s2]=size(ca{1});

Más respuestas (0)

Categorías

Más información sobre Operating on Diagonal 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