I want to do PCA and then MDA (Multiple Discriminative Analysis) in order to reduce the dimensions of the dataset from 99^2 to 49 (face recognition).
My first step was reducing dimensions from 99^2 to 50 by PCA. Now I want to use MDA to reduce from c to c-1 -> from 50 to 49. I've tried this code but I get complex values in the 'Answer', which is wrong.
% calculate PCA
mat_mean = mean(trainData(:));
normalized_train = trainData - mat_mean;
A = normalized_train/std(normalized_train(:));
S1 = A * A';
[V,Z] = eigs(S2,50);
Wpca = A'*V*Z;
% calculate MDA
[Sb,Sw] = scattermat(Wpca);
Sb1=Wpca*Sb*Wpca';
Sw1=Wpca*Sw*Wpca';
[Answer,ready1] = eigs(Sb1,Sw1,49);
Any suggestions what am I doing wrong?
The reason is that "eigs" calculates the eigenvalues of the matrix, which includes SQRT in it... and I have negative values in Sb,Sw