Please help! Timestamp matrix problem, creating new matrices

3 次查看(过去 30 天)
Hi all,
I'm with a problem doing a part of a program, I hope you can help me.
I have this three columns in excel;
it goes until 31-01-2012 23:45
And now I want to read them into matlab and convert them into 3 new matrix with this format;
Timestamp
01-01-2012 00:00
01-01-2012 01:00
(...)
Period
A
C
Price
11,800000
10
So basicly I want a program that read's timestamp and keep's day month year and hour (ignoring the minutes), for that period of time it needs to show the most repetitive value in periods of one hour (for example: it will give A to 00 and C to 01) and finally I want it to sum the prices for that hour (so it will sum the price at 00:15 + price at 00:30 etc.)
It will be a huge help, if you can solve me this problem.
  2 个评论
Walter Roberson
Walter Roberson 2013-12-13
What if there was a 1 hour slot that had two 'D' and two 'E' period markers? Then there is no "most repetitive" period marker.
In the example you show, the Period marker is the same for everything in the first hour, and is different for the second hour but that second value is the same for the entire second hour. In the third hour, can the period again be 'A' or 'C', or is each period marker unique for an hour? Or is it cyclic, repeating at 24 hour intervals?
João
João 2013-12-13
Thanks for responding, in the 1 hour periods I will always have one most repetitive marker (3 of A and 1 C, 3 D and 1 A etc.) I could find in this month 4 markers, A B C D. This markers aren't cyclic but I will find it all across the month, so it will reappear.

请先登录,再进行评论。

回答(2 个)

Walter Roberson
Walter Roberson 2013-12-13
To convert S = '01-01-2012 00:15' to '01-01-2012 00:00' then
S(end-1:end) = '00';

João
João 2013-12-14
编辑:Walter Roberson 2013-12-15
The problem is that I have more than one item with minutes, if I use your method I will obtain
S= 01-01-2012 00:00 , 01-01-2012 00:15, 01-01-2012 00:30, 01-01-2012 00:00.
And I only want to keep the first item ( ex: 01-01-2012 00:00) for each our.
  6 个评论
Walter Roberson
Walter Roberson 2013-12-16
date_myway = timevec(:,[3 2 1 4]);
if your order is D Mon Y H. datevec returns in the order Y Mon D H Min S Frac
João
João 2013-12-16
编辑:João 2013-12-16
Now it's almost doing what I want but after 1-12-2012 23 I'm getting wrong data I'm getting for example 5 7 18 0, hour is correct but the rest is wrong. And I only need one more thing I'm getting each hour repetitive 4 times (ex: 1 1 2012 0, 1 1 2012 0, 1 1 2012 0, 1 1 2012 0, 1 1 2012 1 etc) what do you recommend for not having repetitive dates?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Time Series Objects 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by