% trenovaci mnozina
T = [0.1 4 5 0.2 15 3.8 14 0.4 5; 10 0 1 13 5 0.4 5.9 7 12];

%T = randv2D1([30,-5,1,-5,1; 20,5,2,5,2; 23 4 1 0 4]);

% zobrazeni dat
plot(T(1,:),T(2,:),'o');

% vytvoreni kompeticni site
net = newc([0 15; 0 10],3); % rozsahy hodnot, pocet trid (vystupu)

% matice vah a prahu:
net.IW{1,1}
net.b{1,1}

% ucici funkce
net.trainFcn
% parametry uceni
net.trainParam
%net.trainParam.epochs = 30;
%net.trainParam.showWindow=false;

% nauceni site
vnet = train(net,T);

% matice vah a prahu po nauceni
vnet.IW{1,1}
vnet.b{1,1}

% pouziti site
a = sim(vnet,T);
% a je ridka matice, kde v kazdem sloupci je jedna jednicka

ac = vec2ind(a);

% vykreslen vysledku
ind1 = find(ac == 1);
ind2 = find(ac == 2);
ind3 = find(ac == 3);

% reprezentanti
W = vnet.IW{1,1}

hold on
plot(T(1,ind1),T(2,ind1),'or');
plot(W(:,1),W(:,2),'x');
plot(T(1,ind2),T(2,ind2),'og');
plot(T(1,ind3),T(2,ind3),'ob');
hold off;

% democ1.m
