Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Problem with defining vector x for fmincon
Posted:
Nov 8, 2012 3:23 PM
|
|
Hi,
I would like to do my optimization with MATLAB FMINCON, and my optimization problem has a nonlinear objective function and nonlinear constraints. here is my objective function:
for k=1:6; B(k)=x(2*num+k)*x(fb(k)); C(k)=x(tb(k)); D(k)=2*B(k)*C(k); g=real(Ybr); loss(k)=g(fb(k),tb(k))*((B(k)^2)+C(k)^2-D(k)*cos(x(num+fb(k))-x(num+tb(k))));
end Ploss=sum(loss)
and my constraint:
for i=1:num P(i)=sym(strcat('p',num2str(i))); Q(i)=sym(strcat('q',num2str(i))); end P(1:num)=0; Q(1:num)=0;
%% Non Linear Eqaulity Constraints for i = 1:7 for k = 1:7 P(i) = P(i) + x(i).* x(k).*(g(i,k).*cos(x(num+i)-x(num+k)) + b(i,k).*sin(x(num+i)-x(num+k))); Q(i) = Q(i) + x(i).* x(k).*(g(i,k).*sin(x(num+i)-x(num+k)) - b(i,k).*cos(x(num+i)-x(num+k))); end end
for k = 1:6; N(k)=(x(fb(k))./x(2*num+k))-((xre(k)*(qd(tb(k))- x(3*num+k)))+r(k)*pd(tb(k)))./((x(2*num+k)^2)*x(tb(k)))-x(tb(k)); end ceq =[(pg.'-pd.'-P).';(qg.'-qd.'-Q).';N.']; c=[];
When i run fmincon command i just got different errors such as:
??? Undefined function or method 'max' for input arguments of type 'sym'.
Error in ==> nlconst at 196 mg = max(ga);
I defined my x as:
for i=1:27; x(i)=sym(strcat('x',num2str(i))); end I will highly appreciate if you could give me some hints and help me to do my optimization.
|
|
|
|