function mlpresponse(xrange, w1, w2)

% now create some sample points to plot model behaviour

[Xin,Yin] =  meshgrid(xrange);      % create grid of test points
response_inputs = [Xin(:) Yin(:)];  % convert to N x 2 matrix
[Nresponse, dummy]  = size(response_inputs);


% calculate response to a grid of inputs
[response_outputs, hidden] = mlpforward(response_inputs, w1, w2);

title('Response of MLP after training');
mesh(Xin,Yin,reshape(response_outputs,sqrt(Nresponse),sqrt(Nresponse)));

nhidden = length(hidden(1,:));
figure
for i=1:nhidden
   subplot(2,ceil(nhidden/2),i);
   mesh(Xin,Yin,reshape(hidden(:,i),sqrt(Nresponse),sqrt(Nresponse)));
end