title: How to define Linear program in matlab?
body: <p>I'm having trouble defining my optimization problem in MATLAB.  </p>
  
  <p>I'm trying to express 7 binary decision variables.  but the sum of the first 3 binary decsion varibles cannot be greater than1, and the sum of the last 4 binary decision variables cannot be greater than 1.</p>
  
  <pre><code>A = [1,1,1,0,0,0,0;...
      0,0,0,1,1,1,1];
  b = [1;1];
  
  % objective function 
  f = [0.1, 0.5, 0.2, 0.2, -2.0, 0.2, 0.6];
  
  lb = zeros(7,1);
  ub = ones(7,1); % Enforce all of the decision variables to be binary
  intcon = [];  % all of my variables are binary, so I assume this should be blank.
  
  x = intlinprog(f,intcon,A,b,lb,ub);
  </code></pre>
  
  <p>I want to Enforce all of the decision variables to be binary, so I included these lines:</p>
  
  <pre><code>lb = zeros(7,1);
  ub = ones(7,1); % Enforce all of the decision variables to be binary 
  intcon = [];  % all of my variables are binary, so I assume this should be blank.
  </code></pre>
  
  <p>Also, I have no equality constraints, so I did not include <code>Aeq</code> and <code>beq</code> in the problem above.  but when I try to run the solver without those parameters like<code>x = intlinprog(f,intcon,A,b,lb,ub);</code> it tells me </p>
  
  <pre><code>Error using intlinprog (line 123)
  The number of columns in Aeq must be the same as the number of elements of f.
  </code></pre>
  
  <p>But if I do not have any equality constraints, how am I supposed to define this?</p>
  
  <p>Here is the documentation: <a href="https://www.mathworks.com/help/optim/ug/intlinprog.html#bts3gkc-2" rel="nofollow noreferrer">https://www.mathworks.com/help/optim/ug/intlinprog.html#bts3gkc-2</a>
  The example at the top of the page shows that it can call <code>x = intlinprog(f,intcon,A,b)</code> without using <code>Aeq</code> and <code>beq</code>, so I know it is possible.  </p>
  
  <p>thanks.</p>