Hi,
I want to minimize sum of squared variables in fmincon while get the number of variables from users. For example, if he entered i=3, minimize x(1)^2+x(2)^2+x(3)^2. if he entered i=n, minimize x(1)^2+x(2)^2+...x(n)^2. Actually, I don't have any problem to set lower and upper limits and initial condition matrix, but I don't know how to define this function which fmincon accepts.
Thanks

댓글 수: 1

Matt J
Matt J 2018년 1월 25일
If you have no nonlinear constraints, though, it would be better to use quadprog

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

 채택된 답변

Matt J
Matt J 2018년 1월 24일

0 개 추천

The objective function can be specified independently of the dimension.
fun=@(x) norm(x).^2
It is the initial guess that must be chosen based on the problem dimension.

추가 답변 (0개)

카테고리

태그

질문:

2018년 1월 24일

댓글:

2018년 1월 25일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by