You are on page 1of 6

AZIZ KHOIRUL FATONI

NIM: 13518244011
Pendidikan Teknik Mekatronika

Program
close all, clear all, clc, format compact
% number of samples of each class
N = 20;
% define inputs and outputs
offset = 5; % offset for second class
x = [randn(2,N) randn(2,N)+offset]; % inputs
y = [zeros(1,N) ones(1,N)]; % outputs
% Plot input samples with PLOTPV (Plot perceptron input/target vectors)
figure(1)
plotpv(x,y);

>> x
x=
Columns 1 through 12
1.4193 0.1978 -0.8045 0.8351 0.2157 -1.1480
-0.4390 0.8404 0.1001
0.2916 1.5877 0.6966 -0.2437 -1.1658 0.1049
-1.7947 -0.8880 -0.5445

0.7223 -0.6669 -0.0825


2.5855

0.1873 -1.9330

Columns 13 through 24
0.3035 0.4900 1.7119 -2.1384 1.3546 0.9610 1.4367 -0.1977 7.9080
6.3790 4.5314 6.0984
-0.6003 0.7394 -0.1941 -0.8396 -1.0722 0.1240 -1.9609 -1.2078 5.8252
3.9418 4.7275 4.7221
Columns 25 through 36
5.7015 4.6462
2.9974 5.5201
2.9482 4.1764
5.9642 4.9800

3.4229

5.2820

3.6663

5.3502

5.0229

3.2498

4.1686

3.8436

5.5080

5.0335

6.1275

4.7009

4.7380

4.7143

4.0208

4.4664

Columns 37 through 40
4.9652
4.2018

6.0187
4.8668

4.2855
6.3514

4.7752
4.4110

>> y
y=
Columns 1 through 20
0 0 0 0 0 0

Columns 21 through 40
1 1 1 1 1 1

>> net = perceptron;


net = train(net,x,y);
view(net);

figure(1)
plotpc(net.IW{1},net.b{1});

>> x1=[1 1 0 0; 1 0 1 0]
x1 =
1
1

1
0

0
1

0
0

>> y1=[1 -1 -1 -1]


y1 =
1

-1

-1

-1

>> y1=[1 0 0 0]
y1 =
1

>> plotpv(x1,y1);

>> net1 = perceptron;


net1 = train(net1,x1,y1);
view(net1);

>> figure(1)
plotpc(net1.IW{1},net1.b{1});

You might also like