fmincon how can I solve it?

1 view (last 30 days)
Why is it not working?
function [ J ] = objfun( x )
%Objective function
P=25.0231; E=2; h=2;
J=((P*h)/E)*(1/(X(1)+sqrt(2)*x(2)));
end
function [ c,ceq ]=myconfun22( x )
%Constraint functions
S=0.0092; P=25.0231;
c=[(P*(x(2)+sqrt(2)*x(1))/(sqrt(2)*(x(1)^2)+2*x(1)*x(2))))-17.5;
(P/(x(1)+sqrt(2)*x(2)))-17.5*(1+0.1*S);
(-P*x(2))/(sqrt(2)*(x(1)^2)+2*x(1)*x(2))+1.2;
0.2-x(1);
x(1)-6*(1+0.2)*S;
0.2*(1-0.1*S)-x(2);
x(2)-6];
ceq=[];
What should I do to get the optimized value?
  1 Comment
Walter Roberson
Walter Roberson on 20 Feb 2016
You do not show your call to the optimizer. You also do not indicate what difficulties you are observing.

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 20 Feb 2016
I MIGHT postulate that had you looked carefully at your function, you might have seen that you used both X and x as the variable in this line.
J=((P*h)/E)*(1/(X(1)+sqrt(2)*x(2)));
MATLAB is case sensitive. Should it have known that X is intended to be the same as x? Surely if MATLAB did that, it would be the cause of some nasty bugs along the way.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!