please help me with the error
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I used the following functions to do an optimization problem and got the given error.
Could you please help me correct it.
Thanks
function v = funv(x)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
x1=x(1);
x2=x(2);
x3=x(3);
x4=x(4);
x5=x(5);
v = 46.149*x1+39.158*x2+19.834*x3+59.307*x4+35.526*x5;
end
function [c,ceq] = nlconst(x)
x1=x(1);
x2=x(2);
x3=x(3);
x4=x(4);
x5=x(5);
c=[];
ceq = x1+x2+x3+x4+x5-1;
end
clc;
clear;
A = [];
B = []; % the linear inequality constraints: A*X <= B
Aeq = [];
Beq = []; % the linear equality constraints: Aeq*X = B
LB = [];
UB = []; % LB <= X <= UB
x0 = [1, 1, 1, 1, 1]; % initial guess
[x,FVAL,EXITFLAG,OUTPUT,LAMBDA] = fmincon(@funv,x0,A,B,Aeq,Beq,LB,UB,@nlconst);
ERROR:
Warning: The default trust-region-reflective algorithm does
not solve problems with the constraints you have specified.
FMINCON will use the active-set algorithm instead. For
information on applicable algorithms, see Choosing the
Algorithm in the documentation.
> In fmincon at 486
In sc at 12
Error using nlconst
Too many input arguments.
Error in fmincon (line 794)
[X,FVAL,LAMBDA,EXITFLAG,OUTPUT,GRAD,HESSIAN]=...
Error in sc (line 12)
[x,FVAL,EXITFLAG,OUTPUT,LAMBDA] =
fmincon(@funv,x0,A,B,Aeq,Beq,LB,UB,@nlconst);
0 comentarios
Respuestas (1)
Walter Roberson
el 14 de Ag. de 2013
http://www.mathworks.com/matlabcentral/newsreader/view_thread/38221 and see Eckhard Arnold's reply.
7 comentarios
Walter Roberson
el 14 de Ag. de 2013
Please use
which -all nlconst
to check whether the nlconst.m you are getting is the one you expect.
Ver también
Categorías
Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!