Fill the big gaps in data series

조회 수: 10 (최근 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 CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by