title: Scilab - For loop with changing index
body: <p>I am having trouble with a very simple for loop in Scilab.</p>
  
  <pre><code>max_inventory = 0;
  
  for j=1:120
  
      S(j) = max_inventory + 1;
  
      if (S(j)&lt;90) then
          cost(j) = 27;
  
          elseif (90&lt;=S(j)&lt;=110) then
          cost(j) = 25;
  
          else
          cost(j) = 22;
      end
  
  
      max_inventory = max_inventory + 1;
  
  
  end
  </code></pre>
  
  <p>Basically, I want S to have an index j. So, with 120 iterations, there will 120 different values of S. Namely, S_1, S_2,..., S_120.</p>
  
  <p>With the if-else condition, I want the "cost" to have a different value depending on what S(j) is.</p>
  
  <p>But, I keep getting the error:</p>
  
  <blockquote>
    <p>Undefined operation for the given operands. check or define function
    %b_3_s for overloading.</p>
  </blockquote>
  
  <p>I am not sure what this error really mean.</p>