maxSize=6;

mseErrorAutoenc=zeros([maxSize,1]);
for i=1:maxSize
    ae=trainAutoencoder(trainingData,i,'ShowProgressWindow',false);
    predicted=predict(ae,trainingData);
    mseErrorAutoenc(i)=mse(trainingData-predicted);
end

fig=figure();
subplot(1,3,1);
plot(mseErrorAutoenc)

%PCA
[COEFF,SCORE,latent] = princomp(trainingData);
subplot(1,3,2);
plot(cumsum(latent)./sum(latent))

%NNMF
D=cell(maxSize,1);
for i=1:maxSize
    [W,H,D{i}]=nnmf(trainingData,i);
end

subplot(1,3,3);
plot(diff(cell2mat(D)))