Using fmincon for optimization, when having too many variables
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi guys, I wanted to use the "fmincon" in the optimization toolbox to minimize my objective function. The only problem is that I have many variables. should I manually type the objective function :f(X)=x(1)+x(2)+...+x(n) ? Is there no other way?
Thanks in advance.
댓글 수: 0
채택된 답변
Alan Weiss
2012년 8월 10일
You have to write a function that takes one input, typically a vector called x, and returns the objective function evaluated at x. If your objective function is the sum of the elements in the vector x, as you seem to have, then you could write, for example,
objective = @(x)sum(x);
Alan Weiss
MATLAB mathematical toolbox documentation
댓글 수: 2
Alan Weiss
2012년 8월 14일
Well, if it is really a linear function with a vector of coefficients, you could use
@(x)dot(x,a)
where a is the vector of coefficients.
Alan Weiss
MATLAB mathematical toolbox documentation
추가 답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!