Prev: is bootci with bootfun returning a vector possible? (at least in newer versions of matlab)
Next: How to calculate return series ?
From: H on 18 Jun 2010 01:42 I came up with this not-so-elegant solution: The idea is to find the first and last non-nan indexes and then replace the correspoding nans with them. %vector A=[ NaN NaN NaN 3 6 10 30 100 NaN NaN]; %index of the first non-nan ind1=find(~isnan(A),1,'first'); %index of the last non-nan ind2=find(~isnan(A),1,'last'); %replace the nans in the beginning A(1:ind1-1)=A(ind1); %replace the nans in the end A(ind2+1:end)=A(ind2); |