Simple routine computing a Self-Organizing Map (SOM)
W = SOM(X,K)
Train a 2D SOM on dataset X. In K the size of the map is defined. The map can maximally be 2D. When K contains just a single value, it is assumed that a 1D map should be trained. The output of the mapping contains the (negative) distances to all neurons. To obtain the index of the closest neuron, do A*W*LABELD.
W = SOM(X,K,NRRUNS,ETA,H)
Train the SOM for NRRUNS iterations, using learning rate ETA and a Gaussian neighborhood function with width H*sqrt(MAXD), where MAXD is the maximum distance in the dataset X.
There is the extra feature, that NRRUNS, ETA and H can be vectors, such that it can be run several iterations using larger ETA and H, and after that with smaller values.
Default: K=[5 5], NRRUNS = [20 40 40], ETA = [0.5 0.3 0.1], H = [0.6 0.2 0.01];