user238469
user238469

Reputation:

Unexpected error due to lower and upper limits when using fminbnd function in Matlab

I am using lower limit and upper limit in the fminbnd function according to the legit domain values of my coefficients as following:

[x,fval,exitflag] = fminbnd(@(x) minimize_me(sill, x(1), x(2), x(3), cov), [x1l x2l x3l], [x1u x2u x3u], opts);

Where the [x1l x2l x3l] and [x1u x2u x3u] are the vectors representing the lower limit and upper limit for the optimized coefficients. The domain of my problem is given as following:

0<=x1l<=5
0<=x1u<=5

0<=x2l<=5
0<=x2u<=5

0<=x3l<=180
0<=x3u<=180

The strange problem is that I get an error shown below even for choosing some values within my domain:

??? Error using ==> mtimes
Inner matrix dimensions must agree.

Error in ==> fminbnd at 271
    x = xf + si * max( abs(d), tol1 );

For example I get an error if I choose:

[x1l x2l x3l], [x1u x2u x3u] = [0 0 0], [5 5 180] or [x1l x2l x3l], [x1u x2u x3u] = [1 1 0], [5 5 180] or [x1l x2l x3l], [x1u x2u x3u] = [1 2 0], [5 5 180] etc.

However, I don't get an error if I choose [x1l x2l x3l], [x1u x2u x3u] = [5 5 0], [5 5 180] or [x1l x2l x3l], [x1u x2u x3u] = [3 0 0], [3 5 180] etc.

Upvotes: 0

Views: 892

Answers (1)

Dan Becker
Dan Becker

Reputation: 1214

According to the documentation, fminbnd only works with functions that take a single scalar as an argument.

Take a look at fminsearchbnd on the file exchange:

http://www.mathworks.com/matlabcentral/fileexchange/8277-fminsearchbnd.

Upvotes: 4

Related Questions