Error Not enough input arguments when using nonlcon for Fmincon command

조회 수: 6 (최근 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.

추가 답변 (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