fmincon should return a scalar value error
古いコメントを表示
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 件のコメント
Walter Roberson
2018 年 1 月 25 日
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
2018 年 1 月 26 日
AJEET Kumar
2022 年 8 月 30 日
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
2022 年 8 月 30 日
Take the initial condition in the neighbourhood of the solution you want to get from fmincon :-)
採用された回答
その他の回答 (1 件)
maged salah
2020 年 7 月 20 日
0 投票

3 件のコメント
Walter Roberson
2020 年 7 月 20 日
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
2020 年 7 月 20 日
if you can help ,I need a drawing for this table (parallel,step response)
Walter Roberson
2020 年 7 月 20 日
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
カテゴリ
ヘルプ センター および File Exchange で Solver Outputs and Iterative Display についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

