fmincon should return a scalar value error
Mostrar comentarios más antiguos
Hello,
I am trying to do an optimization for a large function using a "fmincon" function. I have got an error and couldn't find the problem. The main function has so many trigonometric functions (cos, sin. ...). The following is the error obtained :
Error using fmincon (line 609)
Supplied objective function must return a scalar value.
Error in Energy_test2 (line 74)
x = fmincon(objective,x0,A,b,Aeq,beq,lb,ub,'flcon');
The following is the main script using "fmincon". I also have checked the matrices dimensions.
objective = @(x)( cos(x(1)).*sin(x(2))+ ....(cos(t).*cos((Ay)-(x(1)))).*...*Ar*e));
x0 = [2,42];
disp(['initial objective:' num2str(objective(x0))])
A = [];
b=[];
Aeq = [];
beq = [];
x0 = [1,4];
lb = [0,0];
ub = [90,90] ;
nonlinecon = @flcon;
x = fmincon(objective,x0,A,b,Aeq,beq,lb,ub,'flcon');
I appreciate if somebody help with this issue and how can be solved.
Thank you.
Hassan
4 comentarios
Walter Roberson
el 25 de En. de 2018
Difficult to say without the actual objective function and knowing the sizes of the variables involved.
If that is intended to be the actual objective then you need to split the lines properly for us.
Hassan garni
el 26 de En. de 2018
AJEET Kumar
el 30 de Ag. de 2022
Hello sir, Sir how to decide the initial condition in fmincon problem.because fir different initial condition we get different solution.so please ask me any formula for take initial condition.
Torsten
el 30 de Ag. de 2022
Take the initial condition in the neighbourhood of the solution you want to get from fmincon :-)
Respuesta aceptada
Más respuestas (1)
maged salah
el 20 de Jul. de 2020
0 votos

3 comentarios
Walter Roberson
el 20 de Jul. de 2020
This does not appear to be an Answer to the original Question, and does not appear to be an Answer to anything, and also does not appear to be related to any of the earlier discussion ?
maged salah
el 20 de Jul. de 2020
if you can help ,I need a drawing for this table (parallel,step response)
Walter Roberson
el 20 de Jul. de 2020
You should open a new Question for this. When you do, then http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
Categorías
Más información sobre Solver Outputs and Iterative Display en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

