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 ‘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!


3 comments
Thursday, 23rd June, 2005 at 15:02 pm
monoceros
oh dear! At least you found and fixed it.
Friday, 24th June, 2005 at 10:52 am
overacuppa
have found another… it happens a lot when you clean up your scripts… because somethings looks odd and weird and then you try to find the needle in the haysack… the culprit. it’s a pain… but we make mistakes and i do that alot in my amaturish programming. =c(
Friday, 24th June, 2005 at 10:52 am
overacuppa
have found another… it happens a lot when you clean up your scripts… because somethings looks odd and weird and then you try to find the needle in the haysack… the culprit. it’s a pain… but we make mistakes and i do that alot in my amaturish programming. =c(