Error Not enough input arguments when using nonlcon for Fmincon command
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Matt J
le 5 Nov 2015
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;
Réponse acceptée
Matt J
le 5 Nov 2015
Modifié(e) : Matt J
le 5 Nov 2015
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Argument Definitions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!