# Homework Help: Constructing neural netowrk (perceptron)

1. Mar 20, 2007

### nine

1. The problem statement, all variables and given/known data
Implement (AND, NAND) gates using MATLAB.

2. Relevant equations

3. The attempt at a solution
I've succeeded to implement a single perceptron that has a single output and multi inputs.
Here is the code I've written
--------------------------------------------------------------------------
P = [0 0 1 1;0 1 0 1] %Pattern
T = [0 0 0 1] %Target
net = newp(minmax(P),1)
net = train(net,P,T)
--------------------------------------------------------------------------
I need two output terminals, AND results goes to the first terminal and the inverted AND (NAND goes to the other terminal).
I've referred to MATLAB help

Description

train trains a network net according to net.trainFcn and net.trainParam.

train(net,P,T,Pi,Ai,VV,TV) takes

netNetworkPNetwork inputsTNetwork targets (default = zeros)PiInitial input delay conditions (default = zeros)AiInitial layer delay conditions (default = zeros)VVStructure of validation vectors (default = [])TVStructure of test vectors (default = [])

When I tried to rewrite my code with a 2 row target matrix I've got an error as follows

P = [0 0 1 1;0 1 0 1] %Pattern
T = [0 0 0 1;1 1 1 0] %Target
net = newp(minmax(P),1)
net = train(net,P,T)

??? Error using ==> network.train
Targets are incorrectly sized for network.
Matrix must have 1 rows.

Error in ==> AndGate at 4
net = train(net,P,T)

My question is, how can I set two output terminals instead of single output terminal? as I need one terminal for AND gate and the other for NAND gate.

Thanks.
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution