フィルターのクリア

Fill the big gaps in data series

12 ビュー (過去 30 日間)
Andrey Melnikov
Andrey Melnikov 2023 年 8 月 9 日
コメント済み: Star Strider 2023 年 8 月 10 日
Good day!
I have a data series with two big gaps:
For short gaps I usualy used the hermite spline (pchip) or regression (polyfit) but here its not suitable:
Tell me please where can I find a more suitable solution, something like ...
Thanks a lot
  3 件のコメント
Andrey Melnikov
Andrey Melnikov 2023 年 8 月 10 日
Thanks, I'll try
Star Strider
Star Strider 2023 年 8 月 10 日
My pleasure!

サインインしてコメントする。

採用された回答

John D'Errico
John D'Errico 2023 年 8 月 9 日
編集済み: John D'Errico 2023 年 8 月 9 日
The big probem is, your series has little information content in it. :( And of course, you don't give us any data. So I'll make some up. And since I'll be using a few of my own tools that live on the FEX, I'll do it offline.
x = (0:500)';
y = sin(x/300) + randn(size(x))/20;
holes = [200:300,400:450];
unholes = setdiff(1:500,holes);
plot(x(unholes),y(unholes),'b-')
Now, the problem is, if I just connect the first and last points that surround each hole, we get an unwanted effect, in that if those points were high or low, we will get a strange looking curve. It looks instead as if you want a curve that passes through the middle of that noise cloud, following the general trend. That means you need some sort of curve fit, not just an interpolant that looks at the points bounding the holes.
For example, I might have just suggested you use my inpaint_nans tool from the FEX, using the springs option. And it would give you basically that result. You would be unhappy.
Perhas better might be a smoothing spline.
mdl = fit(xuh,yuh,'smoothingspline','smooth',0.0001);
plot(mdl,xuh,yuh)
And that is not at all terrible, but it did depend on my semi-intelligent choice of a smoothing parameter. We could use that function to now fill in the holes, with no problem though.
Another option is my own SLM toolbox. It lives on the File Exchange for free download.
mdl = slmengine(xuh,yuh,'knots',5,'plot','on');
Again, a reasonable curve that will fill in the holes. It needs little in the way of information provided, really only a number of knots to use. Since this is a simple curve, 5 will be entirely reasonable. You really don't care where they fall.
Find SLM here:
Which is better for your specific probem? Probably either could work well enough. There is a strange tweak in your curve at the top end, so I might start with the smoothing spline.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSplines についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by