Path: news.mathworks.com!not-for-mail
From: "Maria Prokopenko" <masha.prokopenko@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: reading date_time in PM/AM format from an ascii file
Date: Sun, 29 Jun 2008 04:41:01 +0000 (UTC)
Organization: USC
Lines: 53
Message-ID: <g473ot$er2$1@fred.mathworks.com>
Reply-To: "Maria Prokopenko" <masha.prokopenko@gmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1214714461 15202 172.30.248.37 (29 Jun 2008 04:41:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 29 Jun 2008 04:41:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1428337
Xref: news.mathworks.com comp.soft-sys.matlab:476450



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