MATLAB: PCA (dimension reduction) in embedded matlab

dimension reductionpca

Hi
I have a 22×22 matrix 'Y' which needs to be dimension reduced to 10 principal values (The principal values are chosen by choosing the top 10 eigenvectors of 'Y') and the remaining rows should be filled with zeros all the while maintaining the order.
I am quite new to matlab so it would be a great help if someone could help me out with the coding.

Best Answer

for i = 1 : 22
for a = 1 : 12
if (i == req_idx(a))
for j = 1 : 22
Y_dr(i,j) = Y(i,j);
end
else
for k = 1 : 22
Y_dr(i,k) = 0;
end
end
end
end
I have written the code as shown above and have used the sort function to get the principal components which gives an ascending or descending order but I need the 'req_idx' variable to be in appropriate order.
Kindly Help !