function y = interp_nan(x) nanx = isnan(x); t = 1:numel(x); y = x; y(nanx) = interp1(t(~nanx), x(~nanx), t(nanx)); end