passing in variables in the nonlcon function in fmincon

조회 수: 2 (최근 30일)
Michelle
Michelle 2012년 11월 5일
Hello,
For my constraint function, I need to pass in a variable that is not a parameter to be optimized. This variable is constantly changing because fmincon is in its for loop. I need this variable to carry out the constraint. I can't find any documentation to help me. The line of code to be altered is:
[X(i,:), negForceDisturbance(i), EXITFLAG(i)] = fmincon(@(X) collisionDetectionOptimizationfmincon(X,Sarrus_Link_Length(i)), X0(i,:), [] ,[] ,[], [], LB, UB,mycon(X,Sarrus_Link_Length), options)
mycon(X,Sarrus_Link_Length) is not correct though. X is the array of parameters and Sarrus_Link_Length is the variable that is always changing but is need in the constraint file.
DO you know what type of syntax I need?

답변 (1개)

Matt J
Matt J 2012년 11월 5일
Wouldn't you pass Sarrus_Link_Length(i) the same way as you did to collisionDetectionOptimizationfmincon?
@(X) mycon(X,Sarrus_Link_Length(i))

카테고리

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