How do I definde interdependent parameters using fminsearch?

Hello,
currently I am using fminsearch to fit a measurement's curve. The (mathematical) function I use depends on 4 parameters (in the following I will call them a, b, c and d). So, far it works fine. I also applied fminserachbnd to add lower and upper boundaries for the parameters.
The problem I have is the following: I want to include further constraints so that a+b>0 and c+d>0 (these constraints have physical reasons).
Is it possible to include this constraints using fminsearch? Which other function can you recommend to solve this problem?
In my oprinion, the problem - and the large difference compared to the boundary conditions or constraints defined in fminsearchbnd or fminsearchcon - is that the values change every loop. How can I make the constraints changing with every new set of parameters calculated during the fitting?
This is the code I use.
model = @TwoDef;
fitParam = fminsearchbnd(model, guess,lb, ub, options);
sse=TwoDef(fitParam);
function [sse, FittedCurve] = TwoDef(params)
a = params(1);
b = params(2);
c = params(3);
d = params(4);
FittedCurve = 1./((1./(a.*X+b))+ (1./(c.*X+d)));
ErrorVector = FittedCurve-Y;
sse = sum(ErrorVector .^ 2);
end

1 个评论

Use lb_a for a and lb_b for b such that lb_a + lb_b >= 0.
This ensures a+b >= lb_a + lb_b >= 0. (Same for c and d).
Best wishes
Torsten.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Mathematics 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by