title: Matlab fmincon - No feasible solution found, but no error caught
body: <p>I'm using the optimisation function "fmincon" and in some case it doesn't converge. I must identify these cases and take the necessary actions, but all the methods used fails in catching the errors, so that I continue to get the error:</p>
  
  <pre><code>No feasible solution found.
  
  fmincon stopped because the size of the current search direction is less than
  twice the default value of the step size tolerance but constraints are not 
  satisfied to within the selected value of the constraint tolerance.
  </code></pre>
  
  <p>First, I tried selecting the exitflag of the function: if it returns a known error (-1, 1, 0...), but each time I had the error, the exitflag returned had a correct value.</p>
  
  <pre><code>[x,fval,exitflag] = fmincon(@(x) costFunction(x,INPUTS),x0,A,b,[],[],lb,ub,[],options);
  if exitflag == 0
      do something;
  end
  </code></pre>
  
  <p>I then tried with the "try/catch" structure, but also in this case, the code continued to run and no error was cought...</p>
  
  <pre><code>try %start try/catch
      [x,fval,exitflag] = fmincon(@(x) costFunction(x,INPUTS),x0,A,b,[],[],lb,ub,[],options);
  catch err
     disp(err.identifier);
         ... actions 
  end  % end try/catch
  </code></pre>
  
  <p>Any suggestion is kindly welcomed.</p>
  
  <p>ps: the options used are:</p>
  
  <pre><code>options = optimset(oldopts,'Display','notify', 'Algorithm','active-set', 'MaxFunEvals', 10000);
  </code></pre>