How to fit a polynomial to a step function??
4 views (last 30 days)
Show older comments
Hi,
I have a noisy step from a scnner result. Is there any way to fit a higher order polynimial to step ? I am not sure which polynomial should work. Attached is the data and figure of my step.
0 Comments
Answers (1)
Walter Roberson
on 28 Mar 2019
No finite polynomial can possibly fit that -- not unless perhaps you swapped axes. What you have is more like a sigmoid function.
What might be acceptable is to fit it as a ratio of polynomials. If you use cftool and select Rational, and ask for numerator order 2 and denominator order 4, the fit is not terrible. (You might have to change the degree and change back again in order to get a fit that does not have singularities.)
2 Comments
Walter Roberson
on 31 Mar 2019
That status is not an error. It says that fmincon found a place it was willing to live with. It would have preferred that the difference between adjacent locations was smaller, but it has reached the minimum step size that you configured in (by default because you pass no options) and would need to take smaller steps to reduce the slope more. You can configure options to permit it to take smaller steps, but probably it would not help.
You appear to be fitting a phased gaussian. Those are notoriously difficult to fit well. When you fit with guassians, one of the common tendencies is for the fitting to push towards a narrow peak with a high phase, which is a adaptation to fit a noise spike.
See Also
Categories
Find more on Linear and Nonlinear Regression 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!