gusl: (Default)
[personal profile] gusl
Array indices start from 1, which means that to properly avoid fencepost errors, your code ends up looking like this:
for day=1:floor(size(p1,2)/24) %for each day
    daytotal(day) = sum(p(24*(day-1)+1:24*(day-1)+24));
end

Lots of extraneous 1s. (And that's because the data is nice: this code can't handle partial days)

I hear NumPy is a very good substitute.

(no subject)

Date: 2008-11-12 06:39 am (UTC)
From: [identity profile] gustavolacerda.livejournal.com
They do start from 1. Try implementing a function that tells you which week the n-th day belongs to.

(no subject)

Date: 2008-11-12 06:53 am (UTC)
From: [identity profile] gwillen.livejournal.com
For bonus perversity points, start numbering the weeks at 1.

(no subject)

Date: 2008-11-12 07:18 am (UTC)
From: [identity profile] gustavolacerda.livejournal.com
I am. At least it's consistent.

February 2020

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags