Why is the fit() function producing a horizontal line above my data?
Show older comments
I am using the MATLAB fit() function (single exponential) to fit the decay of miniature excitaotry post synaptic current (mEPSC) events. It works really nicely for some events, but for others the fitted curve is simply a flat line above my data (see represemtative image for an example of each). I cannot empirically determine any differences between the events where the fit looks good compared to those where the fit produces the horizontal line. Any ideas?
13 Comments
Walter Roberson
on 3 Dec 2022
Do I understand correctly that you are extracting x and y ranges from your data, and fitting each of the segments with exp1 model,
?
(That model can be computed easily with the \ operator after taking log of both sides.)
Luke Fournier
on 3 Dec 2022
Walter Roberson
on 3 Dec 2022
Could you extract the data for that segment near 37 and attach the x and y coordinates here, so that we could test ?
Luke Fournier
on 3 Dec 2022
Torsten
on 4 Dec 2022
I hope you don't work with x-values of about 35000 in the fitting function a*exp(b*x) ...
Luke Fournier
on 4 Dec 2022
Luke Fournier
on 4 Dec 2022
Luke Fournier
on 4 Dec 2022
the cyclist
on 4 Dec 2022
@Torsten, large values of x are OK there, because they can be scaled by the values of b. (But one does need to be careful to specify a good starting value for b to avoid the blow-up that I assume you were cautioning against.)
the cyclist
on 4 Dec 2022
Unless I got myself confused, that model cannot fit the data you posted. exp(b*x) is positive everywhere, so your fitted response values will either all be positive, or all negative (depending on the sign of a). Because your response variable has both positive and negative values, you cannot get a good fit.
Luke Fournier
on 4 Dec 2022
Luke Fournier
on 4 Dec 2022
Luke Fournier
on 4 Dec 2022
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Curve Fitting Toolbox 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!
