Hi,
I'm a new user of Matlab, so I guess this one should be pretty easy.
I have a dated time-series (yyyy-mm-dd) and I want to convert the
dates to Matlab serial dates.
time =3D datenum(dates,'yyyy-mm-dd')
This doesn't seem to work, and I get different errors when I try to
tweak the command and inputs.
First, the dates are in a cell array (icon with { } brackets), and it
seems Matlab prefers it in string (char) format, but I'm not too sure
about this.
I have no problem getting a single date, using datenum(dates{1}) but
when I try to more than one date it tells me Index exceeds matrix
dimensions.
The array is 10183x1, so shouldn't the proper input be datenum(dates{:,
1}) [this means, get the entire column 1, right?)
I want the results to end up in the 'time' vector, and I've tried
different things to solve to matrix dimension issue: 1. creating an
empty 10183x1 vector, 2. creating a completely empty 'time' vector,
and 3. defining it when running the datenum command, as in row 3 of
this post. Nothing works.
If the issue lies in that my dates are in a cell array rather than in
a char, I'm having problems here to since I cannot find a way that
simply lets me convert the array to char.
Any help is very welcolme!
/ Bj=F6rn
|
|
0
|
|
|
|
Reply
|
bjorn.r.jonsson (1)
|
5/7/2010 2:16:26 PM |
|
bjornnak <bjorn.r.jonsson@gmail.com> wrote in message <8134dbc3-b6b9-4e95-b327-3e02332ab7de@k29g2000yqh.googlegroups.com>...
> Hi,
>
> I'm a new user of Matlab, so I guess this one should be pretty easy.
>
> I have a dated time-series (yyyy-mm-dd) and I want to convert the
> dates to Matlab serial dates.
>
> time = datenum(dates,'yyyy-mm-dd')
>
> This doesn't seem to work, and I get different errors when I try to
> tweak the command and inputs.
>
> First, the dates are in a cell array (icon with { } brackets), and it
> seems Matlab prefers it in string (char) format, but I'm not too sure
> about this.
>
> I have no problem getting a single date, using datenum(dates{1}) but
> when I try to more than one date it tells me Index exceeds matrix
> dimensions.
>
> The array is 10183x1, so shouldn't the proper input be datenum(dates{:,
> 1}) [this means, get the entire column 1, right?)
>
> I want the results to end up in the 'time' vector, and I've tried
> different things to solve to matrix dimension issue: 1. creating an
> empty 10183x1 vector, 2. creating a completely empty 'time' vector,
> and 3. defining it when running the datenum command, as in row 3 of
> this post. Nothing works.
>
> If the issue lies in that my dates are in a cell array rather than in
> a char, I'm having problems here to since I cannot find a way that
> simply lets me convert the array to char.
>
> Any help is very welcolme!
>
> / Björn
one of the solutions
d={ % <- a CELL of CHAR strings...
'2000-01-01'
'2001-02-02'
'2010-12-31'
};
dt=datenum(d,'yyyy-mm-dd')
%{
% dt =
730486
730884
734503
%}
% check
datestr(dt)
%{
01-Jan-2000
02-Feb-2001
31-Dec-2010
%}
us
|
|
0
|
|
|
|
Reply
|
us
|
5/7/2010 7:41:04 PM
|
|
|
1 Replies
560 Views
(page loaded in 0.056 seconds)
Similiar Articles: Converting date to serial date (Beginner problem) - comp.soft-sys ...Hi, I'm a new user of Matlab, so I guess this one should be pretty easy. I have a dated time-series (yyyy-mm-dd) and I want to convert the date... Serial date to clarion date - comp.databases.btrieveConverting date to serial date (Beginner problem) - comp.soft-sys ... Serial date to clarion date - comp.databases.btrieve Converting date to serial date (Beginner problem ... time stamp to number conversion - comp.lang.labviewConverting date to serial date (Beginner problem) - comp.soft-sys ... Timestamp conversion problem - comp.databases.mysql... just assign it to a DATE variable ... yyyymmdd to mm/dd/yyyy conversion - comp.soft-sys.matlab ...Converting date to serial date (Beginner problem) - comp.soft-sys ... I have a dated time-series (yyyy-mm-dd) and I want to convert the dates to Matlab ... yyyymmdd to mm ... Timestamp Conversion - comp.protocols.time.ntpConverting date to serial date (Beginner problem) - comp.soft-sys ... Timestamp conversion problem - comp.databases.mysql... just assign it to a DATE variable; the ... get utc time to date vector - comp.soft-sys.matlabConverting date to serial date (Beginner problem) - comp.soft-sys ... get utc time to date vector - comp.soft-sys.matlab Converting date to serial date (Beginner problem ... pick up the number in the brackets....awk way.. - comp.lang.awk ...Converting date to serial date (Beginner problem) - comp.soft-sys ... I want the results to end up in the 'time' vector ... having problems here to since I cannot find a ... wrong week number in date format - comp.databases.ms-access ...Hello, I have a problem within the form where I have date with default ... be very useful rather than using CONVERT to format date ... The serial number is in this format ... awk equivalent to perl's $& - comp.lang.awk... 9]{1,3}.[0-9]{1,3}.[0-9]{1,3}"}{ print RT }' .... You're going to create problems ... equivalent to perl's $& - comp.lang.awk Somebody posted recently on perl.beginners ... Compare numbers - comp.soft-sys.matlabI didn't solve the problem. The deadline for my ... I need to compare that to a format similar to a serial ... rexx ... to format - comp.databases.filemaker Convert DATE ... Converting date to serial date (Beginner problem) - comp.soft-sys ...Hi, I'm a new user of Matlab, so I guess this one should be pretty easy. I have a dated time-series (yyyy-mm-dd) and I want to convert the date... Excel serial date to Day, Month, Year and vise versa - CodeProjectBeginner Articles; Technical Blogs; Submit an ... project of mine, I needed to convert a serial date number ... 123 spreadsheets without date problems. (Note that a serial date ... 7/26/2012 5:46:13 PM
|