how to remove noise from curves and take their derivates
Show older comments
Hello,
I have some curves which are not smooth, I have to take their derivative. therefore first requirement is remove the noise and take the derivative.
I am doing this work through curve fitting using rat35, poly9 etc. and then taking the derivative. but everytime i run the script, result changes slighty.
i am attaching the curve , their zoom version and then warnings which appeared in workspace, would you please guide me how i should handle this issue.
Regards,
Kiran
1 Comment
Rena Berman
on 5 Jun 2024
(Answers Dev) Restored edit
Accepted Answer
More Answers (2)
If you provide a StartPoint in your fit options, the warning will go away and the fit will be the same when you rerun.
However, the differences you see with each run are not meaningful. You get a slightly different result because the start point of the iterative fitting process is different each time, but in this case they all seem to be converging to essentially the same curve.
6 Comments
Matt J
on 16 Jan 2023
would you please elaborate how to provide a start point ?
The StartPoint is one of the options to fit(),
and how to realize that which results should be considered the correct one
The second output from fit() is a goodness of fit measurement. You can experiment with different start points to see if one gives a significantly better gof, but I suspect they will all be similar.
Matt J
on 16 Jan 2023
I would have to see the code. It puzzles me that it would be working for one fit type, but not the other.
Ah, yes. The StartPoint option is only for nonlinear models. So, you cannot and don't need to supply one for the 'polyx' fit types.
Incidentally, order 9 for your polynomials is indeed a bit high, and will make the fit sensitive to small perturbations in the data. You should probably go lower.
Matt J
on 16 Jan 2023
In which case?
Matt J
on 16 Jan 2023
Why would you need another way?
Use a lower order polynomial so that the parameter estimates won't be as sensitive. Or use a non-polynomial model. Image Analyst suggested an exponential fit. A smoothing spline might also work,
Basically, you should experiment with other models to see if a stiffer model would work.
Image Analyst
on 16 Jan 2023
0 votes
You can use sgolayfilt, which is a sliding polynomial fit within the sliding window, however if I were going to take the derivatives of your curves, I'd fit them to an exponential decay (to get a formula with numerical coefficients), which has a known derivative. See my attached exponential decay demo which uses fitnlm. I have many other functions fit with fitnlm, so it you want them, just ask.
Categories
Find more on Digital Filter Analysis 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!


