Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: reading a .txt file with dates
Date: Sun, 3 Aug 2008 19:52:01 +0000 (UTC)
Organization: Pierburg GmbH
Lines: 36
Message-ID: <g75291$49b$1@fred.mathworks.com>
References: <g74s0g$j2h$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1217793121 4395 172.30.248.38 (3 Aug 2008 19:52:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 3 Aug 2008 19:52:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 872224
Xref: news.mathworks.com comp.soft-sys.matlab:483384



"ALEKSANDER " <aleksander.rise.gallala@gmail.com> wrote in
message <g74s0g$j2h$1@fred.mathworks.com>...
> Hi!
> 
> I've got a file in this form:
> dd/mm/yy [integer]
> 
> The first lines of my file (result.txt):
> 30/07/08 161
> 31/07/08 150
> 01/08/08 151
> 05/08/08 160
> 
> And I wish to generate two vectors: x(n) with n as the n'th 
> line in the file, with the dates in the form "datenum", and 
> the other offcourse y(n) with the corresponding numbers.
> 
> to make it all crystall clear: 
> x(1) = datenum(20/07/08) %this is wrong,but u get the idea!
> y(1) = 161
> ...etc
> 
> If the format of the file is difficult to read, I can 
> easily change it, it's matlab-genrated.
> 
> Thanks!
> Aleksander, Norway

The file format is easy to read, by humans and by matlab :-)
Obviously, get the plain numbers first, e.g. using textscan
(you only need to tell textscan that '/' should be treated
as a whitespace - look for the 'Whitespace' parameter in the
doc), and then feed datenum with the properly arranged
numbers, x = datenum(Y, M, D)
regards
Andres