How to find certain index of a diagonal matrix , when a condition meets?
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!