title: MATLAB Index exceeds matrix dimensions
body: <p>So this is code from a book I am looking at done in Matlab. The model array M is initialized, Q is the norm of the difference of the input vector X and the best-matching model. </p>
  
  <pre><code>M = rand(64,2); % initialization of a 64-model SOM array
  
  Q = zeros(64,1); % quantization error
  for t = 1:1000000
      X = rand(1,2); % training input
      % Winner search
          for i = 1:64
              Q(i,1) = norm(X(t,:) - M(i,:));
          end
      [C,c] = min(Q);
  end
  </code></pre>
  
  <p>I get an error 
  Index exceeds matrix dimensions.</p>
  
  <pre><code>Error in som1 (line 8)
              Q(i,1) = norm(X(t,:) - M(i,:));
  </code></pre>
  
  <p>I can see (or think) the error is coming from the indexing of M, but I am not sure why or how I can fix it. 
  Any ideas or guidance would be much appreciated!</p>