Smoothing/splining data with a limit to the slope of the smooth fit
1 次查看(过去 30 天)
显示 更早的评论
I have noisy data with erroneous measurements which I'm trying to smooth and remove outliers to better approximate the underlying "true" value that the data represent. I have a priori knowledge that the magnitude of the slope of the underlying true values cannot be more than a given value, i.e.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1123175/image.png)
In the attached example, there's a series of measurements which are erroneous around 16:25 which violate this condition. I want a way to automatically remove those points before using pchip to smooth and interpolate the data. Is there a MATLAB function already in existence which can do something like this?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1123180/image.jpeg)
2 个评论
John D'Errico
2022-9-13
Be careful, as it is not always perfectly clear what is an outlier from merely the data, when viewed by an automatic scheme. It can be especially difficult when you have blocks of points that you perceive as outliers. It would help if you add a .mat file with some sample data, attached to a comment or to your original question, please.
回答(1 个)
Bruno Luong
2022-9-13
编辑:Bruno Luong
2022-9-13
Using this File Exchange, its is not easy to find a combination of parameters to make it "works". I think it is difficult and the fit is fragile.
load('C:\Users\bruno\Downloads\example.mat')
ti=linspace(min(t),max(t),500);
pp=BSFK(t,x,3,200,[],struct('KnotRemoval','none','sigma',0,'lambda',1e-10));
plot(ti,ppval(pp,ti),'k',t,x,'.r')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1123340/image.png)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!