MATLAB: Fmincon “matrix dimensions must agree” error

fminconMATLABoptimization

I'm not going to post the entire code, but it can be seen in this Github repo on the "optimization" branch. Run the GUI and click the "Optimize" button to get the error, or you can just read the "optimization.m" file. The exact error is below; I was hoping someone could tell me what is going on. It was working yesterday and I haven't changed much. Thank you.
Matrix dimensions must agree.
Error in finitedifferences
Error in computeFinDiffGradAndJac
Error in barrier
Error in fmincon (line 813)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
Error in optimization (line 39)
b_min = fmincon(func, x0, A, c, Aeq, beq, lb, ub, nlc);

Best Answer

Figured out the reason. Apparently the number of nonlinear constraints in fmincon cannot change between iterations.