MATLAB: Fmincon: how should x0 be specified

fminconmultivariableoptimizationunconstrainedx0

I want to minimize a multivariable uncontstrained function with lower and upper bounds. I don't have any information or idea how to define x0 as initial values and cannot accept zero values.Here is the code
obj = @(x) (1-x(1))*(5*x(2)^3+x(2)^2) + x(1)*(0.2*x(2)^3+1.2*x(2)^2);
x0=ones(0,30);
[x,fval] = fmincon(obj,x0,[],[],[],[],[0;30],[1;50])
How should the x0 be specified regarding the bounds of the variables?

Best Answer

The way you specified ‘x0’, it is a ‘0×30 empty double matrix’!
I would specify it as the median of the bounds, so here:
lb = [0;30];
ub = [1;50];
x0 = median([lb ub],2);
producing:
x0 =
0.5000
40.0000
Related Question