It is my understanding that you are trying to write a MATLAB code for MLP method for training and testing of network by multi-layer perceptron for digit recognition.
You may refer to this previously answered question to find more information regarding the same multi layer digit recognition - (mathworks.com).
You may read more about this MATLAB class to gain a better understanding by going through Multi-layer perceptron - File Exchange - MATLAB Central (mathworks.com).