Azzera filtri
Azzera filtri

How does fillgaps work?

8 visualizzazioni (ultimi 30 giorni)
nt_ba
nt_ba il 6 Dic 2019
Risposto: Ondrej Mokrý il 16 Gen 2024
Hello!
I was wondering how https://www.mathworks.com/help/signal/ref/fillgaps.html works. As it is implied, fillgaps replaces any NaNs present in a signal x with estimates extrapolated from forward and reverse autoregressive fits of the remaining samples. As far as i know, an autoregressive model specifies that the output variable depends linearly on its own previous values and on a stochastic term. So, why it is written that forward values are also taken into account?
Is there an equation for the fillgaps command? As well as an explanation of its parameters?
Please, i really need an answer on this topic.
Thanks in advance!

Risposte (1)

Ondrej Mokrý
Ondrej Mokrý il 16 Gen 2024
Consider a signal with only a single gap for simplicity. The function fillgaps takes the context prior to the gap (cropped to length maxlen, if this parameter is set), estimates an AR model for this context (the order of this model can also be set) and uses this model to predict (extrapolate) the missing samples one by one, given the linear dependence governed by the estimated coefficients of the AR model.
For a signal segment x and model order p, we can efficiently perform extrapolation of n samples (e.g., corresponding to length of the gap) as follows:
af = arburg(x, p); % length of the signal x has to be at least p+1
zf = filtic(1, af, flip(x(end-p+1:end)));
prediction = filter(1, af, zeros(1, n), zf); % produces the extrapolated segment of length n
To utilize also the samples coming after the gap, fillgaps repeats the same extrapolation procedure with flipped (reversed) version of this context after the gap. Clearly, this reverse extrapolation has to be flipped again to fit the original signal.
The forward and backward predictions are then linearly cross-faded to produce the final signal filled in the gap.

Categorie

Scopri di più su Conditional Mean Models in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by