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.
0 Comments
Sign in to comment.