i m doing project on neural network. i want a demo code for AND,OR,X-OR or any SMALL APPLICATION in matlab. thanks
A:
I'm not shure waht you need to know. But the logical functions looks like:
X = xor(A,B)
X = and(A,B)
etc.
see also http://www.mathworks.com/access/helpdesk/help/techdoc/ref/xor.html
Fabian
2010-08-25 07:57:19
+3
A:
Here's a simple example of the XOR problem (non-linearly separable):
input = [0 0; 0 1; 1 0; 1 1]'; %#'
target = [0 1 1 0]; %# target = xor(input(1,:), input(2,:));
%# create ANN: 1 hidden layer with 2 neurons,
%# and an output layer with a sigmoid transfer function
net = newpr(input, target, 2);
net.divideFcn = ''; %# no data split (training/testing/validation)
net.trainParam.epochs = 50;
net = init(net);
[net,tr] = train(net, input, target);
output = sim(net, input);
[err,cm] = confusion(target,output)
with a perfect result of:
err =
0
cm =
2 0
0 2
It requires the Neural Network Toolbox
Amro
2010-08-25 13:55:17