Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!o9g2000prg.googlegroups.com!not-for-mail
From: TideMan <mulgor@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to import timestamp (5:48:05 ) to a format ML can handle
Date: Tue, 6 Oct 2009 13:30:19 -0700 (PDT)
Organization: http://groups.google.com
Lines: 36
Message-ID: <1b6bdbb6-0d86-494d-893a-db7beb2d7185@o9g2000prg.googlegroups.com>
References: <1213675765.22507.1254859042177.JavaMail.root@gallium.mathforum.org>
NNTP-Posting-Host: 202.78.152.105
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1254861020 31148 127.0.0.1 (6 Oct 2009 20:30:20 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 6 Oct 2009 20:30:20 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: o9g2000prg.googlegroups.com; posting-host=202.78.152.105; 
	posting-account=qPexFwkAAABOl8VUndE6Jm-9Z5z_fSpR
User-Agent: G2/1.0
X-HTTP-Via: 1.1 bc2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) 
	Gecko/20090824 Firefox/3.5.3,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:575439


On Oct 7, 8:56 am, AMK <kennas...@gmail.com> wrote:
> Hi,
> I have a datafile that I'm reading into ML and am stuck on how to get the timestamp into ML in a form that it will be able to handle.  Here is my current import script.  Any suggestions?  The whole file is tab delimited but the timestamp cell has :, which I hope may be of some help here.
>
> [code]
> fnames = dir('*.ddf');
> dr1 = 10; dc1 = 1; dr2 = 10; dc2 = 1; %This defines where the time is located within the .ddf file
> dtcols = (dr2-dr1)+1; %Defines length of the data column
> dtrows = length(fnames);  %Defines the length of the data rows
> ch1_dt = zeros(dtrows, dtcols);    %Initializes a matrix to store the data
> for n = 1:length(fnames)    %Start the for loop for the file names
>   ch1_dt(n,:) = dlmread(fnames(n).name, '\t', [dr1 dc1 dr2 dc2])'; %Read in the data
>   end %End the loop
> [/code]
>
> Here is a sample of the '\t' delimited datafile:
> date    9/30/2009
> time    5:48:05
>
> Obviously, my next question will be how to import the date too, but that's less critical.
>
> Thanks

Matlab can handle a wide variety of date and time formats, but you
need to import them as strings (like '9/30/2009' and '5:48:05'):
help datenum
Try this:
datestr(datenum('9/30/2009 5:48:05','mm/dd/yyyy HH:MM:SS'))