title: matlab brute force indexing
body: <p>Hi I am working with the brute force method to examine possible combinations of "panels" and "turbines"</p>
  
  <p>My code is </p>
  
  <pre><code> for number_panels = 0:5
  
  for number_turbines = 0:10
  
  
      for n = 1:24 % number of hours per day
  
  
  
  deficit(n) = Demand(n) - (PV_supply(n)*number_panels) -...
   (WT_supply(n)*number_turbines);% hourly power deficit
  
          if deficit(n)&lt;0
  
              deficit(n) = 0;
  
          end
  </code></pre>
  
  <p>The problem I have above is that I haven't yet figured the correct indexing of this code.</p>
  
  <p>What I am trying to do is find the "deficit" for the "number_panels" , "number_turbines" and "n". As it stands I can only find the "deficit" for the last for loop. 
  How can I code so that I can have the option to access the nth row (or sets of "n" i.e 1-24) and also for the "number_panels" "number_turbines" option?</p>
  
  <hr>
  
  <p>thanks - in order to find the sum of each deficit(n) value and thus have the respective total deficit of the 24 hour period I have done the following which seems to me to be able to do what I am asking but I am getting incorrect answers:</p>
  
  <pre><code> daily_deficit(number_panels + 1, number_turbines + 1) =...
   sum(deficit(number_panels + 1, number_turbines + 1,n)) –
  </code></pre>