Minimise functions more than 10 variables

2 views (last 30 days)
Xiangyu Meng
Xiangyu Meng on 1 Oct 2018
Commented: Xiangyu Meng on 2 Oct 2018
I define a function of x with 12 variables as the objective function in fmincon. It gives me the error "Index exceeds array bounds". However, if I reduce the dimension of x to be 9, then everything works well.
Is there a way to minimize a function with more than 10 variables by using fmincon?
  2 Comments
John D'Errico
John D'Errico on 1 Oct 2018
Edited: John D'Errico on 1 Oct 2018
Yes. You can do so by writing code that does not have bugs in it. fmincon does not have a constraint on the number of unknowns. But for us to know what you did wrong would require us to know what code you did write.
Best is if you learn to use the debugger, and find the bug(s) yourself. Then you will know how to debug code for the future.
Xiangyu Meng
Xiangyu Meng on 2 Oct 2018
Yes, I figure it out. It is due to that I assign different dimension to the initial condition.

Sign in to comment.

Answers (0)

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!