%NEWLVQ Create a learning vector quantization network. %NET = NEWLVQ(PR,S1,PC,LR,LF) takes these inputs, %PR - Rx2 matrix of min and max values for R input elements. %S1 - Number of hidden neurons. %PC - S2 element vector of typical class percentages. %LR - Learning rate, default = 0.01. %LF - Learning function, default = 'learnlv1'. %Returns a new LVQ network. clear all; close all; P = [0 0 1; 0 1 0; 0 1 1; 1 0 0; 1 0 1; 1 1 0; 1 1 1]' Tc = [1 2 1 2 1 2 1]; T = ind2vec(Tc); %convert indices to vectors net = newlvq(minmax(P),4,[.6 .4]); net = train(net,P,T); IW = net.IW{1,1}; LW = net.LW{2,1}; save testIW.dat IW -ASCII; save testLW.dat LW -ASCII; load testIW.dat; load testLW.dat; MyTestNet = newlvq(minmax(P),4,[.6 .4]); MyTestNet.IW{1,1} = testIW; MyTestNet.LW{2,1} = testLW; %Y = sim(net,P) %Yc = vec2ind(Y) %Transform vectors to indices. Y = sim(MyTestNet,P) Yc = vec2ind(Y) %Transform vectors to indices.