Error Not enough input arguments when using nonlcon for Fmincon command

10 次查看(过去 30 天)
I have just studied Matlab so i am so sorry if this problem is 'stupid'. I am stuck on dealing error 'Error Not enough input arguments' when i use nonlcon for Fmincon command. Here is my code:
%THE ROBUST RELIABILITY DESIGN METHOD
% Input data: mean value & standard deviation
mD0=1200; stdD0=6;
mD1=1000; stdD1=5;
mF=1.3*10^6; stdF=1.2*10^5;
mr=135; stdr=5.265;
% variable h
syms h
% mean value of limit state equation
mg = mr - 3*mF*(mD0-mD1)/(pi*mD1*h^(2))
% variance of limit state equation
varg = stdr^(2) + (3*(mD0-mD1)*stdF/(pi*mD1*h^(2)))^(2) +...
(3*mF*stdD0/(pi*mD1*h^(2)))^(2) + (3*mF*mD0*stdD1/(pi*mD1^(2)*h^(2)))^(2)
% Standard deviation of limit state equation
stdg=sqrt(varg)
vpa(stdg)
A1=1/stdg;
B=6*mF*(mD0-mD1)/(pi*mD1*h^3);
beta=mg/stdg;
f2 = matlabFunction(A1*B*(exp(-beta^2/2))/(2*pi)^(1/2));
%Using fmincon command to solve The Robust Reliability Design
A=-1; b=-50;
h0=50;
lb = [];
ub = [];
Aeq = [];
beq = [];
nonlcon=@constrain;
fmin = fmincon(f2,h0,A,b,Aeq,beq,lb,ub,nonlcon)
Here is constrain function:
%Constrain function
function [c, ceq] = constrain(h,mD0,stdD0,mD1,stdD1,mF,stdF,mr,stdr)
mg = mr - 3*mF*(mD0-mD1)/(pi*mD1*h^(2));
stdg= sqrt(stdr^(2) + (3*(mD0-mD1)*stdF/(pi*mD1*h^(2)))^(2) +...
(3*mF*stdD0/(pi*mD1*h^(2)))^(2) + (3*mF*mD0*stdD1/(pi*mD1^(2)*h^(2)))^(2));
c = (0.00336*stdg-mg);
ceq = [];
Please help me to solve this problem. Thanks all so much!
  1 个评论
Matt J
Matt J 2015-11-5
Incidentally, inequality constraints like
A=-1; b=-50;
are not a good way to express upper and lower bounds. You should express this as
lb=50;

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2015-11-5
编辑:Matt J 2015-11-5
Define nonlcon as an Anonymous Function
nonlcon=@(h) constrain(h,mD0,stdD0,mD1,stdD1,mF,stdF,mr,stdr);
so that MATLAB knows that it is a function of h with Extra Parameters mD0,stdD0,mD1,stdD1,mF,stdF,mr, and stdr.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Argument Definitions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by