Finding out what initial guesses the curve fitting toolbox made for curve fit

10 views (last 30 days)
Hi everyone, thank you for your time,
I am currently working on a code that inputs real-life indentation data to fit them through a curve fitting toolbox. The relevant code portion is as below:
f1 = fittype('a0+(a1-a0)*((0.491*exp(-0.908*sqrt((abs(a3)*x)/(C0^2))))+(0.509*exp(-1.679*sqrt((abs(a3)*x)/(C0^2)))))','problem','C0')
f = fit( Hx, Hy, f1, 'problem', C0, 'lower',[0,0,0])
As you can see, I have not specified starting conditions, because we work with different tissues that each have different local minima (which creates non-fits). So I am letting MatLab randomize the starting points ( coeffiecient a0,a1,a3) to get global minima.
I am currently using r2 comparison to choose the best results. What I am also interested is recording what initial values Matlab chose for a0,a1 and a3 for the better runs (higher r2) so that I can make separate codes for particular tissues with preset inital guesses.
Thank you all for your time.
Muhtadi Zahin
Muhtadi Zahin on 20 Oct 2021
Edited: Muhtadi Zahin on 20 Oct 2021
I'm working with different biological samples. My idea is that I make versions of the code with different initial values corresponding with different biological tissues, so that the results are out more quickly. Also because I do not think that one set of initial values will work for all sample results.
As for intial value and not final values, I just think that the variability in biological data makes it better if I know a valid range of "casting net" to work on. Basically, I want to have a record of the range of initial values that best "caught" a range of fit-curves, if I'm making any sense.

Sign in to comment.

Accepted Answer

Matt J
Matt J on 20 Oct 2021
Edited: Matt J on 21 Oct 2021
I don't think there's anyway to dig out the initial guess generated inside fit(), but why not just specify your own random start point(s)? I can't imagine there's any advantage to letting fit() do it internally.
Also, note that your problem can be reduced to a single unknown (a3) as below. You might be able to do a simple one-dimensional parameter sweep for an accurate initial guess a3_0.
fun=@(a3) mdl(a3,Hx,Hy,C0); %1D function of a3
a3=fminsearch( fun, a3_0); %a3_0 = initial guess of a3
function [resnorm,coeffs]=mdl(a3,x,y,C0)
x=x(:); y=y(:);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by