Hi, Benard
A perceptron can be created with the newp function.
Eq: net = newp(PR,S,TF,LF);
- PR is m x 2 matrix of [min max] of network input
- S is a scalar that indicates number of target/pattern
- TF is transfer function. Default is 'hardlim'
- LF is learning function. Default is 'learnp'
In order to divide your data into 2 groups, you need to select A1, B1, C1 as network input.
p = [A1(1:end); B1(1:end); C1(1:end)]';
And to create the network target
t = eye(3);
Then, use train to perform network training. You can also set the network epoch by :
net.trainParam.epochs = 10;
So, the complete code is :
p = [A1(1:end); B1(1:end); C1(1:end)]';
t = eye(3);
PR = zeros(63,2);
PR(:,2) = 1;
net = newp(PR,3,'hardlim','learnp');
net.trainParam.epochs = 10;
net = train(net, p, t);
And about how to test your network just use sim command.
a = sim(net, A2(1:end)');
Now, do testing for A1 and A2. Both of them will display :
>> a = sim(net, A2(1:end)')
a =
1
0
0
>> a = sim(net, A1(1:end)')
a =
1
0
0
Best Answer