Azzera filtri
Azzera filtri

plz explain what does this code do..?

3 visualizzazioni (ultimi 30 giorni)
praveen singathi
praveen singathi il 20 Mar 2021
Commentato: praveen singathi il 21 Mar 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});

Risposta accettata

KSSV
KSSV il 20 Mar 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});

Più risposte (0)

Categorie

Scopri di più su Operating on Diagonal Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by