title: Matlab linprog error - The number of rows in A must be the same as the number of elements of b
body: <p>Hi I have the following code for a linprog optimisation.</p>
  
  <pre><code>for j = 1:2
  
   for i = 1:24
     for K = 1:3
        for M = 1:3
  
     PV_output(:,:,:) = real(PV_power_output(:,:,:));
           WT_output(:,:,:) =  WT_power_output(:,:,:);
  
           PVenergy = sum(sum(PV_output(:,:,1)));
           WTenergy = sum(sum(WT_power_output(:,:,1)));
  
  
            f= [((CRF*CC_PV)/PVenergy)+OM_PV; ((CRF*CC_WT)/WTenergy)+OM_WT];
  
           A(:,:,:) = [-PV_output(:,:,K) -WT_output(:,:,M)];
  
  
              b(:,:) = -Demand(j,i);
  
             lb = zeros(2,1);
  
  
             ub = [max_PV_area/PV_area max_WT_area/WT_area]';
  
        end
     end
    end
   end
  
              x(:,j,i,K,M) = linprog(f,A,b,[],[],lb,ub)
  </code></pre>
  
  <p>Where WT_output and PV_output are 3 dimensional 365x24 arrays and Demand is 365x24</p>
  
  <p>I am trying to optimise x1 and x2 for each of the 365x24 elements of Demand and for each dimension so as to find the optimum K and M combination</p>
  
  <p>However as the code currently stands I keep getting the error - "The number of rows in A must be the same as the number of elements of b."</p>
  
  <p>Does anyone have any suggestions?</p>