How to fill a large gap in a sine wave?

조회 수: 1 (최근 30일)
carolina
carolina 2020년 7월 23일
댓글: neil jerome 2020년 7월 27일
Hi, this is a follow up to a previous question of mine. I am trying to fill a gap in a sine wave using the fillgaps function as described here - https://uk.mathworks.com/help/signal/examples/reconstructing-missing-data.html#ReconstructingMissingDataExample-6
I have tried to do this but as you can see in my image below, it is not working for me. It is drawing a straight line instead of correctly predicting the wave.
Below is an image of the code I am using in matlab:
Could someone please advise me on what I might be doing wrong? Do I need to use another function instead? Thanks in advance for your help.
MATLAB release version: 9.5.0.1298439 (R2018b) update 7
  댓글 수: 3
carolina
carolina 2020년 7월 23일
I see, thanks for your reply. Do you know what the maximum gap that can be filled is?
KSSV
KSSV 2020년 7월 23일
If the data is periodic ... one can replace the missing data with existing ...

댓글을 달려면 로그인하십시오.

채택된 답변

Roger J
Roger J 2020년 7월 23일
You can try something like the following:
temp_reconstructed = fillgaps(tablecomplete.table_temperature,80,50);
Where I have maximum prediction-sequence length of 80 samples and a model order of 50. I don't know what you will use for your data, but you can play around with it.
  댓글 수: 3
carolina
carolina 2020년 7월 27일
Thanks for your help. I have some long gaps with 8000 samples covering approximately two months from some weather stations. I specified the maximum number of samples and the model order with the function fillgaps() and it does work with my datasets. I decided not to interpolate weather stations with long gaps of more than 8000 samples.
I have another question about when I specify the model order - how can I determine it correctly when I have a long gap and a short gap with few samples in the same signal?
neil jerome
neil jerome 2020년 7월 27일
this will get a bit philosophical! for a small and large gap in the same data, if you find an acceptable answer for the long gap then it should also fill the short gap satisfactorily, although this would be vastly overpowered compared to what you would need if there were only the small gap. but you should probably use the same parameters for both gaps, since you are (probably) implicitly assuming that the data has the same underlying properties throughout. but some might argue that you should try to use the minimum necessary assumptions to create an answer, which would mean a reduced order/points for small gaps. again, i would use known data, deliberately blank out sections of your choice, and then try to recreate using different strategies and then compare back to the truth. but then you would ideally try this for all combinations of missing data and gap size, so you can easily get into a mess. the important thing is to explicitly recognise which assumptions you're making :)
so when you say 'correctly' determine, that might be a wild goose chase, so be careful. the bottom line is that the missing data simply isn't there, so you cannot ever know what is actually correct. something strange might have happened in the weather that day and you will never know! what you are doing is artificially creating data that 'doesnt look wrong', but not more than that! it doesn't - cannot - add more information than you already have, and in the worst case could be misleading (if something weird really did happen that day, and you recreated a normal day to sit in its place). if your analysis can't cope with missing data, adding in artificial data that is based on the extant data can only ever mimic the information already there, so what are you really adding? anyway, you see what i mean about getting philosophical! the criteria for 'success' are yours to decide, so in the end it depends what your goal is, and as long as you state exactly what you did (and why).
just my thoughts :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by