title: Wrong matrix multiplication causes number of elements not being the same
body: <p>I have this matrix</p>
  
  <pre><code>mpsim =
  
     1.0e+04 *
  
     -2.2331
     -0.4261
      1.3810
      3.1880
      4.9951
      6.8022
      8.6092
  </code></pre>
  
  <p>this matrix</p>
  
  <pre><code>fvsim =
  
         NaN       NaN       NaN       NaN       NaN       NaN       NaN
         NaN       NaN       NaN       NaN       NaN       NaN       NaN
           0         0    0.9000    0.1000         0         0         0
           0         0         0    0.7500         0    0.2500         0
           0         0         0         0         0    1.0000         0
           0         0         0         0    0.5000         0    0.5000
           0         0         0         0         0         0    1.0000
  </code></pre>
  
  <p>and this matrix</p>
  
  <pre><code>lingsim =
  
       3
       3
       3
       3
       3
       3
       3
       3
       3
       3
       4
       4
       4
       4
       6
       5
       6
       7
       7
  </code></pre>
  
  <p>I'm trying to use this code but got an error</p>
  
  <pre><code>sizeA=size(mpsim,1);
  sizeB=size(fvsim,1);
  sizeC=size(lingsim,1);
  outputsim = zeros(size(lingsim));
  for i=1:sizeC
      if lingsim(i)&lt;=sizeB
          outputsim(i)=sum(mpsim * fvsim(lingsim(i), :)); 
      else 
          outputsim(i)=lingsim(i);
      end
  end
  outputsim
  </code></pre>
  
  <blockquote>
  <pre><code>In an assignment  A(I) = B, the number of elements in B and I must be the same.
  
  Error in ftskutes (line 131)
          outputsim(i)=sum(mpsim * fvsim(lingsim(i), :));
  </code></pre>
  </blockquote>
  
  <p>How to fix this? Actually I'm assuming that <code>sum(mpsim * fvsim(lingsim(i), :));</code> is 1x1 but when I try to check it is  1x7.</p>