How do i fit my data with two functions and a knot between them

3 vues (au cours des 30 derniers jours)
artu' breuer
artu' breuer le 27 Jan 2017
Commenté : artu' breuer le 6 Fév 2017
I am trying to fit the data in the graph below. The fit should be composed of two functions.
f(x) for x<k
g(x) for x>k
I do not know if it is needed but this are the two functions:
f(x) = 3/4*b*((a-x)/a-(a-x)^3/3a^3+2/3)+c
g(x) = d
The function g(x) is just a constant line and should fit the data approximately between 3.5 and 7. a,b and c are parameters of the fit.

Réponse acceptée

Sky Sartorius
Sky Sartorius le 27 Jan 2017
Modifié(e) : Sky Sartorius le 27 Jan 2017
The tanh function can be handy for creating a one-liner piece-wise function for feeding into a curve fitting tool. If you don't have the curve fitting toolbox, check out https://www.mathworks.com/matlabcentral/fileexchange/10176. In the ezfit tool, I can ask it to fit my own equation of the form:
(0.5-tanh((x-k)/eps)/2)*(F1) + (0.5+tanh((x-k)/eps)/2)*(F2);
In your case, replace F1 and F2 with your fit functions:
(0.5-tanh((x-k)/eps)/2)*(3/4*b*((a-x)/a-(a-x)^3/3*a^3+2/3)+c) + (0.5+tanh((x-k)/eps)/2)*(d);
You can also get some a priori information from your data that will help constrain the problem and help it converge to a good fit, for example you can bound d to be between the min and max of your data y values, and similarly for k and the data x values.

Plus de réponses (0)

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by