add contraints on parameters defined in function
Ältere Kommentare anzeigen
I have a function:
y =x.^a + z.^b
For which I wrote a separate function as I neet to fit it over my data. But I want to add constraint: a>b. How will I do that? Please help me with it. Thanks
5 Kommentare
Walter Roberson
am 19 Jan. 2018
What do you want to have happen if the caller attempts to violate the constraints?
John D'Errico
am 19 Jan. 2018
Bearbeitet: John D'Errico
am 19 Jan. 2018
It is meaningless to say you have a constraint on a and b, because the function does not constrain them. A function is just a function. It does not care what you give it.
You want to use a fitting tool to fit some data, but you do not tell us which tool that is. That is the tool which must understand that the parameters are constrained, NOT the function to be fit.
So you need to use a tool that can handle inequality constraints on the parameters. And as it turns out, few such tools do allow general linear inequality constraints. But you could formulate the problem to be fit using fmincon.
Or, you could redefine the model to be in the form
y = x.^(a+b) + z.^b
where a was specified to have a lower bound of 0. Many tools allow bound constraints on the parameters.
Giru Mishra
am 19 Jan. 2018
Torsten
am 19 Jan. 2018
Use "lsqcurvefit" together with the model function y=Const*(x^(c1+c2)+z^c1) and include the bound constraint c2>0.
Once lsqcurvefit has determined c1 and c2, a=c1+c2 and b=c1 in your original model.
Best wishes
Torsten.
Giru Mishra
am 19 Jan. 2018
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!