How does fmincon work? Why does this syntax not work?

S(1)=20; S(2)=20; S(3)=20; P(1)=20; P(2)=15; Umin=1; Umax=220; x0=[1 1 1 1 1 1 1 1]; A=[ 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 -1 0 -1 0 -1 0 0 0 0 -1 0 -1 0 -1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0]; B=[S(1) S(2) S(3) -P(1) -P(2) Umax Umax Umin Umin S(1) S(1) S(2) S(2) S(3) S(3) 0 0 0 0 0 0 ]; [x,fval]=fmincon(@objEx61,x0,A,B)
//here is the object function function [f]=objEx61(x) ro=0.145; l(1)=3; l(2)=4; l(3)=2; l(4)=6; l(5)=3; l(6)=5; Umin=1; Umax=220; a=3.56; b=1370.2; c=106310; Cw=170; Tj=4000; Cp=4500; i(1)=(a*x(7)^2+b*x(7)+c)*l(1); i(2)=(a*x(8)^2+b*x(8)+c)*l(2); i(3)=(a*x(7)^2+b*x(7)+c)*l(3); i(4)=(a*x(8)^2+b*x(8)+c)*l(4); i(5)=(a*x(7)^2+b*x(7)+c)*l(5); i(6)=(a*x(8)^2+b*x(8)+c)*l(6); I=i(1)+i(2)+i(3)+i(4)+i(5)+i(6); W=(x(1)+x(2)+x(3)+x(4)+x(5)+x(6))*Cw*Tj; E=Cp*ro*((1/(x(7)^2)*x(1)^2*l(1))+(1/(x(8)^2)*x(2)^2*l(2))+(1/(x(7)^2)*x(3)^2*l(3))+(1/(x(8)^2)*x(4)^2*l(4))+(1/(x(7)^2)*x(5)^2*l(5))+(1/(x(8)^2)*x(6)^2*l(6)); f=I+W+E;
//this is the error Error using feval Error: File: objEx61.m Line: 25 Column: 159 Unbalanced or unexpected parenthesis or bracket.
Error in fmincon (line 601) initVals.f = feval(funfcn{3},X,varargin{:});
Error in matEx6 (line 31) [x,fval]=fmincon(@objEx61,x0,A,B) Caused by: Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.

댓글 수: 1

Read the error message. You have too many or too few parens or brackets in one or more of your expressions.
Just look carefully at your code.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Argument Definitions에 대해 자세히 알아보기

태그

질문:

2016년 11월 19일

댓글:

2016년 11월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by