%% Decode Encoded Data For New Images  

%% 
% Load the training data. 
X = digitTrainCellArrayData;

%%
% |X| is a 1-by-5000 cell array, where each cell contains a 28-by-28 matrix
% representing a synthetic image of a handwritten digit.  

%% 
% Train an autoencoder using the training data with a hidden size of 15. 
hiddenSize = 15;
autoenc = trainAutoencoder(X,hiddenSize);  

%% 
% Extract the encoded data for new images using the autoencoder. 
Xnew = digitTestCellArrayData;
features = encode(autoenc,Xnew);  

%% 
% Decode the encoded data from the autoencoder. 
Y = decode(autoenc,features); 

%%
% |Y| is a 1-by-5000 cell array, where each cell contains a 28-by-28 matrix
% representing a synthetic image of a handwritten digit.   



%% 
% Copyright 2012 The MathWorks, Inc.