fminsearch with if statement
2 views (last 30 days)
I need to optimise two parameters by minimising by objective function.
I've got an equation that has got two parts.
The parameters that I want to optimise are p0 and b0.
I already got the vectors obs and p.
The equation is:
If p < p0, then sim = p +b0*p0
if p>= p0, then sim = 5
Then I need to put my simulated values into my objective function, that looks like:
OF = (sim - obs)^2
So, now I want to minimise OF using fminsearch.
How can I do that, if the parameter that I am looking for is inside the constraint?
More Answers (1)
Edited: Matt J on 26 Jul 2013
Looks like you're doing a first order spline fit with a single free knot, and therefore this FEX file might already do everything you need,