How to fill a large gap in a sine wave?
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Roger J
on 23 Jul 2020
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 Comments
neil jerome
on 27 Jul 2020
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 :)
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!