Wednesday, 22 June, 2005

i found a bug!

crikey... been mulling over some bizarre numbers for weeks... and i think i know why now... hope this de-bugging will clean up the mess... it's all <~isnan>'s fault!

test...

EDU>> t=[1:10 NaN]

t =

1 2 3 4 5 6 7 8 9 10 NaN

EDU>> mean(t(~isnan(t)))

ans =

5.5000

EDU>> mean(t(1:end-1))

ans =

5.5000

EDU>> mean(t(~isnan(t(3:end))))

ans =

4.5000

EDU>> mean(t(3:end-1))

ans =

6.5000

EDU>> (3+4+5+6+7+8+9+10)./8

ans =

6.5000


EDU>> (t(~isnan(t(3:end))))

ans =

1 2 3 4 5 6 7 8

EDU>> (t(~isnan(t)))

ans =

1 2 3 4 5 6 7 8 9 10

EDU>> t(t(~isnan(t)),3:end)
??? Index exceeds matrix dimensions.

EDU>> t(t(~isnan(t)),3:end-1)
??? Index exceeds matrix dimensions.

EDU>> (t(~isnan(t)),3)
??? (t(~isnan(t)),3)
|
Error: ")" expected, "," found.

EDU>> (t(~isnan(t),3:end))
??? Index exceeds matrix dimensions.

EDU>> t(~isnan(t))

ans =

1 2 3 4 5 6 7 8 9 10

EDU>> T=t(~isnan(t))

T =

1 2 3 4 5 6 7 8 9 10

EDU>> T(3:end)

ans =

3 4 5 6 7 8 9 10

EDU>> mean(T(3:end))

ans =

6.5000


baaaah!

posted by ~overacuppa~ at 13:04 hrs, on 22 June, 2005 | Comments (2)