From: dpb on 22 Jul 2010 22:38 Luna Moon wrote: .... > I think your "ismember" is used wrongly... > it has a bug... I have no "ismember" and that was pasted directly from command window... >> x=[1;1;2;1;2;3;NaN;NaN;3;2;NaN;NaN;NaN;4;1;5;2;NaN;3]; >> z=[nan;nan;x] z = NaN NaN 1 1 2 1 2 3 NaN NaN 3 2 NaN NaN NaN 4 1 5 2 NaN 3 >> idx=max(1,min(find(~isnan(z)))) idx = 3 >> all(isnan(z(idx:end))==isnan(x)) ans = 1 >> --
From: Oleg Komarov on 23 Jul 2010 03:26
Luna Moon > The key part is how to do back-fill fast! % Final input example TS = { '1/1/2010' NaN '1/2/2010' NaN '1/5/2010' 2.3 '1/6/2010' NaN '1/7/2010' NaN '1/8/2010' 3.1}; % Find running streaks of NaN except the first toFill = findseq(cell2mat(TS(:,2)),1); % on FEX findseq toFill = toFill(isnan(toFill(:,1)) & toFill(:,2)~=1,:); % Fill TS TS(toFill(2):toFill(3),2) = TS(toFill(2)-1,2) TS = '1/1/2010' [ NaN] '1/2/2010' [ NaN] '1/5/2010' [2.30] '1/6/2010' [2.30] '1/7/2010' [2.30] '1/8/2010' [3.10] Oleg |