MATLAB: Question about “newp” function in neural network toolbox

neural networknewptutorial

net = newp([-2 2;-2 +2],1);
I'm trying to learn about neural network on my own by reading the tutorial there's one part i don't understand about 'newp' function. all the example given, they use [-2 2,-2 +2] i couldn't figure out why this combination is used.
looking at the help file, it says:
Syntax net = newp(p,t,tf,lf) where P – RxQ matrix of Q1 representative input vectors. T – SxQ matrix of Q2 representative target vectors.
isn't RxQ & SxQ suppose to be the vector size? such as 3×2 the example seems to use P as [-2 2;-2 +2] and T as 1
any clarification is deeply appreciated. Thank you.

Best Answer

net = newp([-2 2;-2 +2],1);
The square -2 <= x1 <= 2 , -2 <= x2 <= 2 is defined as the region where the output is supposed to be unity. Otherwise, it should be zero.
Syntax net = newp(x,t,tf,lf) where
x - IxN matrix of N representative I-dimensional input vectors.
t - OxN matrix of N corresponding representative O-dimensional output target vectors.
close all, clear all, clc
net = newp([0 1; -2 2],1) % "Ones" rectangular region, R, is defined
view(net)
x = [ 0: 0.1 : 1; -2: 0.4 : 2] % Eleven points within R
y = net(x) % y = ones(1,11)
%Now we define a problem, an OR gate, with a set of four 2-element input vectors x and the corresponding four 1-element targets t.
x = [ 0 0 1 1; ...
0 1 0 1 ]
t = [ 0 1 1 1 ] % t is one if x1 or x2 is one
% Here we simulate the network's output, train the net and then simulate it again
y = net(x) % 1 1 1 1
e = t-y % -1 0 0 0 error vector
MAE = mae(e) % 0.25 mean-absolute error
% Train the net to reduce the MAE. it will stop when converged
net = train(net,x,t);
y = net(P) % 0 1 1 1
e = t-y % 0 0 0 0
MAE = mae(e) % 0
Hope this helps
Thank you for formally accepting my answer
Greg