title: Manipulating matrices in Matlab using fmincon
body: <p>I'm currently trying to use fmincon in Matlab.</p>
  
  <p>I can get it to operate correctly, but this falls over when i include manipulation of matrix elements which don't meet a condition.</p>
  
  <p>As below</p>
  
  <pre><code>ub = 1.1;
  lb = -1.2; 
  aut = -0.25;
  
  h = @(aut)eQ_Optim(aut);
  
    u = fmincon(h,aut, [], [], [], [], lb, ub)
  </code></pre>
  
  <p>The function i'm using is as follows</p>
  
  <pre><code>                function [Maxim]   = eQ_Optim(aut); 
  
                   Data = [-0.23183483,-0.003274012;
                           -0.289945477,0.000282334;
                           -0.483591973,0.006588649;
                           -0.257735378,0.000887691;
                           -0.286463622,-0.003235662;
                           -0.453939127,0.004358216;
                           -0.196363243,0.004186609;
                           -0.209783591,0.001715187];
  
  
     Data(Data(:,1)&lt;aut,2)=0
  
                       MDOnx=Data(:,2)+1;
                       MD_Cumx=cumprod(MDOnx,1);
                       Maxim = MD_Cumx(end)*-1
  
  
   end
  </code></pre>
  
  <p>I'm trying to get fmincon to optimise the variable 'aut', such that it maximises the cumulative sum of the right hand column (Data(:,2)).</p>
  
  <p>for reference, the output i'm receiving is </p>
  
  <p>Initial point is a local minimum that satisfies the constraints.</p>
  
  <p>Optimization completed because at the initial point, the objective function is non-decreasing 
  in feasible directions to within the default value of the optimality tolerance, and 
  constraints are satisfied to within the default value of the constraint tolerance.</p>
  
  <p></p>
  
  <p>u =
    -0.250000000000000</p>
  
  <p>Which as you can see, is just my original guess being fed back to me.</p>
  
  <p>I hope everything is clear. I've simplified everything as much as possible. Is this possible?</p>