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

Walter Roberson
Walter Roberson 2016년 2월 20일
You do not show your call to the optimizer. You also do not indicate what difficulties you are observing.

댓글을 달려면 로그인하십시오.

 채택된 답변

John D'Errico
John D'Errico 2016년 2월 20일

1 개 추천

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.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by