listing bab 13
LAMSTAR CODE ( MATLAB ) Main.m clear all close all X = train_pattern; %pause(1) %close all n = 12 % Number of subwords flag = zeros(1,n); % To make 12 subwords from 1 input for i = 1:min(size(X)), X_r{i} = reshape(X(:,i),6,6); for j = 1:n, if (j<=6), X_in{i}(j,:) = X_r{i}(:,j)’; else X_in{i}(j,:) = X_r{i}(j-6,:); end end % To check if a subword is all ’0’s and makes it normalized value equal to zero % and to normalize all other input subwords p(1,:) = zeros(1,6); for k = 1:n, for t = 1:6, if (X_in{i}(k,t)~= p(1,t)), X_norm{i}(k,:) = X_in{i}(k,:)/sqrt(sum(X_in{i}(k,:).^2)); else X_norm{i}(k,:) = zeros(1,6); end end end end%%%End of for %%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Dynamic Building of neurons %%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Building of the first neuron is done as Kohonen Layer neuron %(this is for all the subwords in the first input pattern for all SOM modules i = 1; ct = 1; while (i<=n), i cl = 0; for t = 1:6, if (X_norm{ct}(i,t)==...