Error Not enough input arguments when using nonlcon for Fmincon command

10 ビュー (過去 30 日間)
Skies1228
Skies1228 2015 年 11 月 5 日
コメント済み: Skies1228 2015 年 11 月 5 日
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.
  1 件のコメント
Skies1228
Skies1228 2015 年 11 月 5 日
Thank you so much for quickly reply. It already worked.^^

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeArgument Definitions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by