%% Script file: NGScript01.m % Load the data. In this case, make the data: dim x num pts (column-wise) load SixDatasets; X=XX{3}; X=X'; %Transpose the data so that they are column-wise clear XX; % Initialize the training parameters (This was copied from initng.m: [M,N]=size(X); % Parameters need to be set up first: C.NC=20; %Number of clusters C.lr=[0.3 0.05]; %initial, final learning rate epsilon C.nbr= [0.01*N 0.01]; %initial, final lambda (neighborhood size) C.tcon=[5*N 80*N]; %initial, final time (for connection matrix) C.tmax=200*N; %max number of iterations C.epochs=1; %number of epochs (each epoch runs tmax iterations, % and resets the training parameters after each.) C.tflag=1; %Training flag: 1=Use Connection, 0=Do not use Id=randperm(N); C.cen= X(:,Id(1:C.NC)); %Initialize the centers randomly from the data C.M=zeros(C.NC,C.NC); %Initialize the connection matrix (if tflag=1) %% Call the Neural Gas function: % Data should be in columns C=NeuralGas01(X,C); %% Plot the result cidx=plotng01(C); hold on plot(X(1,:),X(2,:),'k.'); plot(C.cen(1,:),C.cen(2,:),'r*'); hold off