Custom Fit Fit options
Show older comments
I have created a custom fittype and tried let MATLAB itself find the starting point, given lower and upper bounds that I specify. However, those bounds seem to have been ignored when the fit process was performed (see attachments). Does anyone know how I can force MATLAB to search for the coefficients between the bounds I have specified? Thank you.
Answers (1)
The bounds weren't ignored. You defined them in "Options", but just forgot to pass Options to the fitting routine.
4 Comments
J.S.
on 25 Jun 2018
Matt J
on 25 Jun 2018
It would help us both if you would copy/paste your code and errors/output into your posts, rather than communicating them via screenshots. That way, it is easier for people to copy/paste modifications of the code for you.
J.S.
on 25 Jun 2018
Well, the problem is probably that you are now constraining b,d to a region where the exp() operations overflow to infinity, as in the following:
>> exp(1000)
ans =
Inf
You need to double-check the magnitudes of (x-x0) to be sure that range is sensible.
One other remark. I recommend reformulating the model as follows
U=[1,(-1/(1e-6)),1,-1];
HOF=fittype('a*exp(b*X)+c*exp((b+d)*X)',...
'coefficients',{'a','b','c','d'},'independent','X');
f_normTEST=fit(binTimeCol-x0,bindataColNorm-y0,HOF,Op);
There are 2 main changes. First, the input data is pre-offset by x0,y0 so that the fitting routine doesn't have to repeat it unnecessarily in every iteration. Second, one of the exponential parameters is now represented as b+d. This tells the solver that those parameters are meant to be nonequal, since that would make a,c ambiguous.
Categories
Find more on Linear Predictive Coding in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!