Borrar filtros
Borrar filtros

How to find certain index of a diagonal matrix , when a condition meets?

1 visualización (últimos 30 días)
I have the following code:
covar = 1.0/m .* X' * X; % computing co-variance
[U, S, V] = svd(covar); % singular value decomposition % U contains principal components and V contains diagonal matrix
% %% % % ===== Dimensioanlity Reduction Finding K for projection======
s3=sum (diag(S));
sum1=0;
temp1=0;
for j=1:length(S)
sum1=sum1+S(j,j);
div_res=(sum1/s3);
if(div_res==0.9)
index=find(j) ;
end
end
All I want is, that value of "j" when the div_res=>0.9 but I am not getting the correct answer

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 25 de Abr. de 2014
n=size(A,1);
idx=find(A(sub2ind([n n],1:n,1:n))>=0.9)

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