
% create some sample points to plot model behaviour
xrange = [-2:0.1:2];                % grid resolution
[Xin,Yin] =  meshgrid(xrange);      % create grid of test points
response_inputs = [Xin(:) Yin(:)];  % convert to N x 2 matrix
[Nresponse, diminputs]  = size(response_inputs);


% initialise the weight vector (add one to include the bias term
% w0 as first entry of input
w1 = randn(diminputs+1,1);


% calculate input activation (sum of product of weights with inputs)
activation = [ones(Nresponse,1) response_inputs]*w1;
% calculate the threshold function of activation
y_thresh = activation > 0;
% calculate a sigmoid function of activation
y_sigmoid = 1./(1+exp(-activation));


fprintf('Plotting results\n');
figure(1)
title('Response of threshold function');
mesh(Xin,Yin,reshape(y_thresh,sqrt(Nresponse),sqrt(Nresponse)));

figure(2)
title('Response of sigmoid function');
mesh(Xin,Yin,reshape(y_sigmoid,sqrt(Nresponse),sqrt(Nresponse)));



