optimization function fmincon with a transfer function

Dear Sir, How can i use the optimization function "fmincon" or any other if the optimization function is a transfer function and also the constraints are dependent up on a transfer functions also. Thank you

回答(1 个)

You have to be able to evaluate the objective function for fmincon to work. So, how do you evaluate a transfer function as a function of the optimization parameters? Answer that, and you'll be able to use fmincon.
Alan Weiss
MATLAB mathematical toolbox documentation

3 个评论

I'd like to show you my problem in details and the error message i get may you can help me
the objective function is:
function f=qfunction(x) f=tf([x(1) x(2)],[1 1340 448900]);
the constraints
function [c,ceq]=constraints(x) T_con_num=[44296000*x(1)+1.894e+11 44296000*x(2)+3.8556e+14 2.6159e+17 5.915e+19]; T_con_den=[1 1.784e+4 1.6099e+8 3.8231e+11 4.477e+14 2.6159e+17 5.915e+19]; W2_num=[1 1.784e+4 1.6099e+8 1.9291e+11-44296000*x(1) 6.2144e+13-44296000*x(2)-3.7363e-6*x(1) 7.4476e-5*x(1)-3.7363e-6*x(2)+4.9173 7.4476e-5*x(2)-104.484]; W2_den=[1 1.783956e+4 1.6099e+8 3.82308e+11 4.477e+14 2.61587e+17 5.9149777e+19]; W2=tf(W2_num,W2_den); t=0:0.001:0.1; y1_d=0.5*step(W2_num,W2_den,t); y2_d_num=34.558*W2_num; y2_d_den=conv([1 0 4.7769e+5],W2_den); y2_d=impulse(y2_d_num,y2_d_den,t); y3_d_num=conv([0.1 0],W2_num); y3_d_den=conv([1 0 1.1942e+5],W2_den); y3_d=impulse(y3_d_num,y3_d_den,t); y_d=y1_d+y2_d+y3_d; ypk=step(T_con_num,T_con_den,t); y_tot=ypk+y_d; c=[max(ypk)-1.2; norm(W2,inf)-1.3; max(y_tot)-1.1]; ceq=[];
The optimization file
x0=[1;1]; options=optimoptions(@fmincon,'Algorithm','sqp'); [x,fval,exitflag,output]=fmincon(@qfunction,x0,[],[],[],[],[],[],@constraints,options);
The error message is:
Error using fmincon (line 788) FMINCON requires all values returned by user functions to be of data type double.
Error in optimization (line 3) [x,fval,exitflag,output]=fmincon(@qfunction,x0,[],[],[],[],[],[],@constraints,options);
Please mark your code with the {} Code button so we have a chance of reading it.
Alan Weiss
MATLAB mathematical toolbox documentation
Dear Alan Weiss thank you for your interest in replying my question, please find the attached MATLAB m files for my problem. I hope if you can help me. Thank you

请先登录,再进行评论。

类别

Community Treasure Hunt

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

Start Hunting!

Translated by