MATLAB: Function or constraints have too few arguments on the right to satisfy the left

fminconoptimizationOptimization Toolbox

I'm trying to optimize this equation:
f=@(x) 0.25*7850*pi^2*x(1).^2.*x(2).*x(3)
with this set of constraints:
g=@(x) [8*75./x(5)-7; 3.5-2*pi*sqrt(75^2/(4*75.*x(4)-x(5).^2)); 100*exp(-pi.*x(5)./sqrt(4*75.*x(4)-x(5).^2))-15; x(2)-0.75; 75*9.81.*(1.566.*x(1).^2-0.9295.*x(1).*x(2)-2.546.*x(2).^2)./(x(1).^3.*(x(1)-x(2)))-517.1*10^6; 78*10^9.*x(1).^4./(8.*x(2).^3.*x(3))-x(4)];
I'm using the fmincon function in the Optimization toolbox, but no matter what algorithm I select, I see the error "The right hand side of this assignment has too few values to satisfy the left hand side" with no further details. I have been trying to figure out the cause of this error, but I'm having difficulty figuring out what, specifically, the error is referring to.

Best Answer

Your nonlinear constraints need to be in a function of the form
function [c, ceq] = g(x)
c = [8*75./x(5) .......
ceq = [];
end
MATLAB was complaining because there was no equality constraint information being passed out (even there are no equality constraints).