Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: reading date_time in PM/AM format from an ascii file
Date: Sun, 29 Jun 2008 14:12:01 +0000 (UTC)
Organization: Draeger Medical Systems Inc
Lines: 69
Message-ID: <g4857h$cib$1@fred.mathworks.com>
References: <g473ot$er2$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1214748721 12875 172.30.248.35 (29 Jun 2008 14:12:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 29 Jun 2008 14:12:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1150820
Xref: news.mathworks.com comp.soft-sys.matlab:476477



"Maria Prokopenko" <masha.prokopenko@gmail.com> wrote in
message <g473ot$er2$1@fred.mathworks.com>...
> Hello,
> i am trying to read into Matlab ascii files  (part of the
> first line is given here as an example, then the same string
> repeats 7 more times, 8 total, in a each row of each file)
> 
> 4/7/2008 3:02:42 AM	0.245	2.924686e-009 
> 
> I need to convert the dates into numerical form, so i can
> time-average the data etc.
> 
> I am trying to use textscan to read the am/pm format of the
> dates, and while this does read 'AM' or 'PM' as a string i
> cannot convert the whole string back into a date_time
> format. that's what i am doing:
> 
> eims = [];
>  E = dir('EIMS_ascii_formatted');
>  cd EIMS_ascii_formatted\
> for i =3:length(E)    
>     eims_file_name = E(i).name;
>     disp(eims_file_name)
>     fid = fopen(eims_file_name);
>    
>     eimst =  textscan(fid,['%d/%d/%d %d:%d:%d %s %f32 %f32
> %d/%d/%d %d:%d:%d %s %f32 %f32 
> %d/%d/%d %d:%d:%d %s %f32 %f32 
> %d/%d/%d %d:%d:%d %s %f32 %f32 
> %d/%d/%d %d:%d:%d %s %f32 %f32 
> %d/%d/%d %d:%d:%d %s %f32 %f32 
> %d/%d/%d %d:%d:%d %s %f32 %f32
> %d/%d/%d %d:%d:%d %s %f32 %f32'],[72 inf]');
>  
>    eims_dates(:,1)=eimst{1};
>    eims_dates(:,2)=eimst{2};
>    eims_dates(:,3)=eimst{3};
>    eims_dates(:,4)=eimst{4};
>    eims_dates(:,5)=eimst{5};
>    eims_dates(:,6)=eimst{6};
>    eims_dates(:,7)=eimst{7}; (% here the problem comes: AM
> or PM is not read%)
> 
> % i also tried%
> 
> eims_dates=eimst(:,1:7); % this did not work either%
> 
>    fclose(fid);
>    end
>   eims_dates = datenum(eims(:,1:7))
> 
> 
> My code does not work. Any help will be very much appreciated,
> 
> Masha

The datestr command might be helpful.  I have not tried it
with your code example, because I am not at work, where I
run Matlab.  There are examples of use at the Mathworks help
desk.

>>help datestr 

or

http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/datestr.html&http://www.mathworks.com/cgi-bin/texis/webinator/search/?db=MSS&prox=page&rorder=750&rprox=750&rdfreq=500&rwfreq=500&rlead=250&sufs=0&order=r&is_summary_on=1&ResultCount=10&query=datestr&submitButtonName=Search

Regards,
Georgios