please tell me right command(fmincon) to get output for this problem
Show older comments
THIS IS THE MAIN FUNCTION
function [f] = myfun(x)
wcg=2.1; %gain cross over frequency
bb=4;
cc=60;
r = x(1) + (x(2)*(wcg^(-x(4)))*cos(90*x(4)*(pi/180)))+ (x(3)*(wcg^(x(5)))*cos(90*x(5)*(pi/180)));
s = - x(2)*wcg^(-x(4))*sin(90*x(4)*pi/180)+ x(3)*wcg^(x(5))*sin(90*x(5)*pi/180);
fun1=bb/sqrt((cc*wcg)^2 +1);
fun2=sqrt((r)^2 + (s)^2);
f = 10*log10(fun1*fun2);
end
ANOTHER PROGRAM FOR CONSTRAINTS
function [c, ceq] = confun(x)
wcg=2.1;
wt=10;
ws=0.01;
aa=2;
bb=4;
cc=60;
dd=80;
ff=0;
fipm=80; %phase margin
r = x(1) + ( x(2)*(wcg^(-x(4)))*cos(90*x(4)*(pi/180)) )+(x(3)*(wcg^(x(5)))*cos(90*x(5)*(pi/180)));
% pi/180 give degree value in radians
s = - x(2)*(wcg^(-x(4)))*sin(90*x(4)*(pi/180))+ x(3)*(wcg^(x(5)))*sin(90*x(5)*(pi/180));
ru = -x(2)*x(4)*(wcg^(-x(4)-1))*cos(90*x(4)*(pi/180))+ x(3)*x(5)*(wcg^(x(5)-1))*cos(90*x(5)*(pi/180));
su = -x(2)*x(4)*(wcg^(-x(4)-1))*sin(90*x(4)*(pi/180))+ x(3)*x(5)*(wcg^(x(5)-1))*sin(90*x(5)*(pi/180));
rt = x(1) + x(2)*(wt^((-x(4))))*cos(90*x(4)*(pi/180))+ x(3)*(wt^x(5))*cos(90*x(5)*(pi/180));
st = -x(2)*(wt^(-x(4)))*sin(90*x(4)*(pi/180))+x(3)*(wt^x(5))*sin(90*x(5)*(pi/180));
rs = x(1) + x(2)*(ws^(-x(4)))*cos(90*x(4)*(pi/180))+ x(3)*(ws^x(5))*cos(90*x(5)*(pi/180));
ss = -x(2)*(ws^(-x(4)))*sin(90*x(4)*(pi/180))+ x(3)*(ws^x(5))*sin(90*x(5)*(pi/180));
%1 equation(41)
c1 = (atan(s/r)*180/pi)-(atan(dd*wcg)*180/pi)-(wcg*ff)+180-fipm;
% 180/pi give radian value in degrees
%2 equation(42)
c21 = 1/(1+(s/r)^2);
c22 = (su*r-s*ru)/(r)^2;
c23 = dd/(1+(dd*wcg)^2);
ceq = [c1;c21*c22-c23-ff];
%3 equation(43)
c31 = aa*sqrt((rt^2) + (st^2));
c32 = sqrt((1+aa*rt)^2 + (dd*wt+aa*st)^2);
c3 = (10*log10(c31/c32))+20;
%4 equation(44)
c41 = sqrt((cc*ws)^2 +1);
c42 = sqrt((1+bb*rs)^2+(cc*ws+bb*ss)^2);
c4 = (10*log10(c41/c42))+20;
c=[c3;c4];
end
PLEASE TELL ME THE RIGHT COMMAND TO BE WRITTEN IN COMMAND WINDOW,THE COMMAND I HAVE GIVEN IS UNABLE TO FIND THE RIGHT SOLUTION
>> x0=[6.7441;27.7461;0.0063;0.1461;0.7874];
>> options=optimset('Algorithm','active-set');
>> [x,fval,exitflag,output,lambda,grad,hessian]=fmincon(@myfun,x0,[],[],[],[],[],[],@confun,options)
BY GOING THROUGH DIFFERENT EXAMPLES IN MATLAB HELP ,I GAVE THESE COMMAND BUT I AM UNABLE TO GETHT SOLUTION ............PLEASE HELP.
9 Comments
Sargondjani
on 11 May 2012
i think you have to leave out the @, so just;
fmincon(myfun,x0,[],[],[],[],[],[],confun,options)
(that's what i always do)
but pls provide the error message if this doesnt work...
kintali narendra
on 11 May 2012
kintali narendra
on 11 May 2012
Sargondjani
on 11 May 2012
so, your problem is solved, right?
kintali narendra
on 12 May 2012
Sargondjani
on 12 May 2012
so you should add them as constraints:
lb=[0,0,0,0,0];
and if you want to have higher bound on the last two: hb=[inf,inf,inf,1,1];
kintali narendra
on 13 May 2012
Sargondjani
on 13 May 2012
you mean the objective function has a better value at your initial guess than the final result???
the only logical explanation seems to be that the initial guess does not satisfy the constraints... You should check this. If it doesnt, than there is probably a typo in your constraints (easily possible witht his long code)
If you are certain this is not the case (which would surprise me), than maybe you can show the exit message, and the function/objective value at the initial guess? That would probably be helpfull in finding the problem....
kintali narendra
on 17 May 2012
Answers (0)
Categories
Find more on Choose a Solver in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!