%% Specify Maximum Gap
% Create a time vector t in seconds and a corresponding vector of data A that contains NaN values.

t = seconds([2 4 8 17 98 134 256 311 1001]);
A = [1 3 23 NaN NaN NaN 100 NaN 233];

% Fill only missing values in A that correspond to a maximum gap size of 250 seconds. Since the second gap is larger than 250 seconds, the NaN value is not filled.

F = fillmissing(A,'linear','SamplePoints',t,'MaxGap',seconds(250))

% Copyright 2020 The MathWorks, Inc.