## Element-wise multiplication of duration and double array

### Amir Rashidi (view profile)

on 11 Oct 2015
Latest activity Answered by Rob Purser

### Rob Purser (view profile)

on 12 Oct 2015
Hi, I try to calculate the energy in a time series dataset. I calculate the power for each record i.e. every hour. Now i would like to compute the energy for each row. I used the :diff" to find the duration for each row and then multiply that duration to power value to calculate the energy. however the final product is duration format. could you please help me with that?
Date Power (W)
'01-Jan-2005 00:00:00' 362374.8161
'01-Jan-2005 01:00:00' 290296.1116
'01-Jan-2005 02:00:00' 96520.39268
'01-Jan-2005 03:00:00' 96491.92618
'01-Jan-2005 04:00:00' 96420.53794
the code I used so far:
A = diff(dispt);
P(1, : ) = [];
E = P.*A;

dpb

### dpb (view profile)

on 11 Oct 2015
It appears the doc 'See Also' section is quite lacking in the duration object section -- couldn't find any of those w/o knowing they existed already.
But, does look like that's the manner by which to get there.
I hadn't really developed any being any particular representation; I've not got enough machine to be able to load/run the latter revisions so all I can do is try to guess as best as can from the doc's what/how to get from here to there...as noted, there being no links from either datetime nor duration to the hours|minutes|seconds, etc., conversion routines was just hoping the casting operations would manage...
Walter Roberson

### Walter Roberson (view profile)

on 11 Oct 2015
The cross reference is definitely lacking.
dpb

### dpb (view profile)

on 11 Oct 2015
Indeed...obtw, on the comment regarding datenum resolution; they can get to about 10 usec...
>> eps(now)*86400/1e-6
ans =
10.0583
>>