MATLAB: How to switch from fminsearch to fmincon

fminconfminsearchMATLAB

Hello,
I am trying to curve-fit a two-parameter model to some exp. data to determine the two parameter of the model.
The code I am using is from an online example which I have modified accordingly (I am new to MATLAB….) and it gives me nice fits, however the values for the two constant i am getting range in [0, inf] and as a result have no physical meaning. I would like to introduce some limits to the search (lb, ub) but when I try to switch from fminsearch to fmincon I get error msgs of the type 'FMINCON only accepts inputs of data type double'
In sort, I am trying to switch from this:
[k0,ss0] = fminsearch(@myodeLSS,k00,[],data);
to this:
[x,fval] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub)
and introduce lb and ub in the search, but it just won't happen…
Any help appreciated…
Thanks

Best Answer

At the risk of sounding patronising, I guess the first question is whether your inputs really are doubles. That error message is trying to tell you something! =)
Use the class() function on each of the matrices/values you are passing into the function to tell you if they are of type double.