How to fill a large gap in a sine wave?

2 次查看(过去 30 天)
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