function [Y,Z,neto,neth]=mlpnn(W,X)

%
% Multilayer (Two Layers) Perceptron Neural Network;
%
% Inputs: W - Cell with the coeficients matrices; 
%             Each cell represent a layer; 
%         X - matrix with the input patterns as column;
%
% Output: y - Outputs of the network; 
%         Z - Outputs of the hidden layer; 
%      neto - Activation of the neurons in the output layer; 
%      neth - Activation of the neurons in the hidden layer; 
%

[N,K]=size(X);

% Hidden Layer;
neth=W{1}*[X;ones(1,K)];
Z=tanh(neth);

% Output Layer;
neto=W{2}*[Z;ones(1,size(Z,2))];
Y=tanh(neto);
