%% Matrix with Missing Endpoints
% Create a matrix with missing entries and fill across the columns (second dimension) one row at a time using linear interpolation. For each row, fill leading and trailing missing values with the nearest non-missing value in that row.

A = [NaN NaN 5 3 NaN 5 7 NaN 9 NaN;
     8 9 NaN 1 4 5 NaN 5 NaN 5;
     NaN 4 9 8 7 2 4 1 1 NaN]

%

F = fillmissing(A,'linear',2,'EndValues','nearest')

% Copyright 2012 The MathWorks, Inc.