fmincon should return a scalar value error
Mostra commenti meno recenti
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 Commenti
Walter Roberson
il 25 Gen 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
il 26 Gen 2018
AJEET Kumar
il 30 Ago 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
il 30 Ago 2022
Take the initial condition in the neighbourhood of the solution you want to get from fmincon :-)
Risposta accettata
Più risposte (1)
maged salah
il 20 Lug 2020
0 voti

3 Commenti
Walter Roberson
il 20 Lug 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
il 20 Lug 2020
if you can help ,I need a drawing for this table (parallel,step response)
Walter Roberson
il 20 Lug 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
Categorie
Scopri di più su Solver Outputs and Iterative Display in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

