% trenovaci mnozina
P = rands(2,1000);
P = randv2D1([30,-5,1,-5,1; 20,5,2,5,2; 23 4 1 0 4]);
P = mapminmax(P);

% vytvoreni kohonenovy mapy
net = newsom([0 1; 0 1],[5 7]); % rozsahy hodnot, mrizka
% net = newsom([0 1; 0 1],[30]); % retizek
% net = newsom([0 1; 0 1],[5 7], 'gridtop');  
% net = newsom([0 1; 0 1],[5 7], 'randtop');  

% net = newsom([0 1; 0 1],[5 7],'hextop','boxdist'); 
% 'dist','mandist', 'linkdist'(default),'boxdist'

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

% nauceni site
net.trainParam.epochs = 50;
vnet = train(net,P);

% vykresleni site
% plotsom(vnet.iw{1,1},vnet.layers{1}.distances)
% plotsompos(vnet,P);

T = [0.5 0.1 1 0.3; 0.3 0.2 0.1 0.9];
% pouziti site
a = sim(vnet,T);

% demosm2.m
pr = 0;
if (pr)
    load simpleclass_dataset
    net = newsom(simpleclassInputs,[8 8]);
    net = train(net,simpleclassInputs);
    plotsompos(net,simpleclassInputs);
end