Mercurial > hg > octave-nkf
changeset 13778:b0b6aa4f7302
__patch__: correctly replace NaN values with last non-NaN value in column
* __patch__.m (setdata): Use loop to replace NaN values with last
non-NaN value in column. Previous vectorized solution failed for
matrices that had columns with no NaN values.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 01 Nov 2011 13:19:10 -0400 |
parents | df98c216da32 |
children | 7c0fcabd1a66 |
files | scripts/plot/private/__patch__.m |
diffstat | 1 files changed, 4 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/private/__patch__.m +++ b/scripts/plot/private/__patch__.m @@ -239,12 +239,10 @@ nc = size (faces, 1); idx = faces .'; t1 = isnan (idx); - if (any (t1(:))) - t2 = find (t1 != t1([2:end,end],:)); - idx (t1) = idx (t2 (cell2mat (cellfun (@(x) x(1)*ones(1,x(2)), - mat2cell ([1 : nc; sum(t1)], 2, ones(1,nc)), - "uniformoutput", false)))); - endif + for i = find (any(t1)) + first_idx_in_column = find (idx(:,i), 1); + idx(first_idx_in_column+1:end,i) = idx(first_idx_in_column,i); + endfor x = reshape (vert(:,1)(idx), size (idx)); y = reshape (vert(:,2)(idx), size (idx)); if (size(vert,2) > 2)