필터 지우기
필터 지우기

error in fmincon function

조회 수: 2 (최근 30일)
Aakash Divakar
Aakash Divakar 2021년 6월 6일
댓글: Aakash Divakar 2021년 6월 6일
clear all;
clc;
objective=@(r)((r(2))*(-25)*(2^(1-max(r(2)/(8*r(3)),r(2)/r(4)))))/(15*r(1))+ 2*(r(5)/r(1));
r0= [1 25 120 100 1000];
A= [];
b= [];
Aeq= [];
beq= [];
lb= [1 10 70 100 500];
ub= [7 40 120 110 600];
nonlcon= @nclon1;
function [c,ceq] = nclon1(r)
c = r(1)^2 + r(2)^2 + r(3)^3 + r(4)^4 + r(5)^5 - 1;
ceq = [];
end
%Function
r= fmincon(objective,r0,A,b,Aeq,beq,lb,ub,nonlcon);
%Results
disp(r) %Values
disp(objective(r)) %Points
error msg:
Error:
Function definitions in a script must appear at the end of the file.
Move all statements after the "nclon1" function definition to before the first local function
definition.

채택된 답변

Manas Minnoor
Manas Minnoor 2021년 6월 6일
Hi Aakash,
Any function definition in a script must be at the end. You may not follow a function definition with unrelated code.
Please refer to this link as this question has already been answered.
Hope this solves it.
  댓글 수: 3
Manas Minnoor
Manas Minnoor 2021년 6월 6일
Do you have the optimization toolbox installed?
See the following:
https://in.mathworks.com/matlabcentral/answers/491764-unrecognized-function-or-variable-getipoptions
Aakash Divakar
Aakash Divakar 2021년 6월 6일
thanks man

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile 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!

Translated by