How to switch from fminsearch to fmincon?

1 Ansicht (letzte 30 Tage)
Nicolas Ioannidis
Nicolas Ioannidis am 18 Mär. 2012
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

Akzeptierte Antwort

Geoff
Geoff am 19 Mär. 2012
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.
  1 Kommentar
Nicolas Ioannidis
Nicolas Ioannidis am 20 Mär. 2012
Hey Geoff,
Thanks for your suggestion. I used class() function and indeed one of my inputs ('data') is a structure. However what I don't understand is, since 'data' is a structure how come I don't get the same error message when I run fminsearch. Also, do you have any idea what the two brackets between 'koo' and 'data' are for? Thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by