Element-wise multiplication of duration and double array

조회 수: 4 (최근 30일)
Amir Rashidi
Amir Rashidi 2015년 10월 11일
답변: Rob Purser 2015년 10월 12일
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;
  댓글 수: 10
Walter Roberson
Walter Roberson 2015년 10월 11일
The cross reference is definitely lacking.
dpb
dpb 2015년 10월 11일
Indeed...obtw, on the comment regarding datenum resolution; they can get to about 10 usec...
>> eps(now)*86400/1e-6
ans =
10.0583
>>

댓글을 달려면 로그인하십시오.

답변 (1개)

Rob Purser
Rob Purser 2015년 10월 12일
The result of the diff on dispt (which I assume is a datetime) is a duration. You will want to convert the duration to a double before doing math on it using a function like hours or seconds.
-Rob

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by