datestr datenum problem with year conversion.

3 次查看(过去 30 天)
Hello I have the following issue,
I am pulling out data from a Quandl, I get the following the set :
The syntax to pull out is the following :
Quandl.get('USTREASURY/YIELD', 'trim_start', '1990-01-02', 'trim_end', '2014-09-12', 'authcode', 'jtwf2XzCdzxhAKrXxNkm')
Time Series Collection Object: USTREASURY/YIELD
Time vector characteristics
Start date 02-Jan-1990 00:00:00
End date 12-Sep-2014 00:00:00
Member Time Series Objects:
x1Mo
x3Mo
x6Mo
x1Yr
x2Yr
x3Yr
x5Yr
x7Yr
x10Yr
x20Yr
x30Yr
Say this set is called YC.
By typing YC.Time or YC.x1Mo.Time, I get the datenum but it allocated the start date which is 02-Jan-1990 00:00:00 as 0 then increment till the end date which is 9019.( 9 sept 2014)
See a sample here
0 1 2 3 6 7 8 9 10 14 15 16 17
When i make a datestr of this matrix, I get a straight integer increment for year 1990, to now, that is 1990 is taken as 0 and ends as 0024, which stands for 2014.
See Sample
00/01/0000 00:00:00 01/01/0000 00:00:00 02/01/0000 00:00:00 03/01/0000 00:00:00 06/01/0000 00:00:00 07/01/0000 00:00:00 08/01/0000 00:00:00 09/01/0000 00:00:00 10/01/0000 00:00:00 14/01/0000 00:00:00 15/01/0000 00:00:00 16/01/0000 00:00:00 17/01/0000 00:00:00
I have tried also things like this datestr(YC.Time,'dd/mm/yyyy HH:MM:SS') but does not work.
I have the impression, the year is non existent in the time vector and it has only month and date and allocates an incremental year number till now.
Do you know how I can make this time vector starts from 1990 and continue till now.
I can code something to make this work in a loop, but I fear there is a much easier way to do that using may be pivot year, which I cannot seem to find.
Thanks you very much.
D.

采纳的回答

Chad Greene
Chad Greene 2014-9-15
Is this what you're looking for?
months = [0 1 2 3 6 7 8 9 10 14 15 16 17];
datestr(datenum(1990,1+months,2))

更多回答(1 个)

dpb
dpb 2014-9-15
Time series objects seemingly use the differential time internally; use the getabstime method to return the actual time vector it seems. I've not used it so this is just reading the doc's...

类别

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