From: Peter Smith on 28 Jul 2010 17:16 Hi all, your help would be much appreciated on this matter. I have approximately 200,000 files containing stock data and i am trying to aggregate these into daily files. However the times of my files start from 07:30 proceed uptil 12:59 and then go from 01:00 to 06:00. I want to ultimately change the times to "minutes past midnight" , i.e. 08:00 will be recorded as 480. I have written this code: for k=1: length(tmpTime) thisTime = tmpTime{k}; thisHour = str2num(thisTime(1:2)); thisMinute = str2num(thisTime(4:5)); if thisHour<7; thisHour = thisHour+12; end; thisMinuteOfDay = 60*thisHour +thisMinute; end However it does not seem to be working properly as when i run the code it does not seem to change tmpTime to minutes past midnight. Could someone please offer any reccommendations? Many thanks
From: Rune Allnor on 28 Jul 2010 17:29 On 28 Jul, 23:16, "Peter Smith" <fe0...(a)mail.wbs.ac.uk> wrote: > Hi all, your help would be much appreciated on this matter. I have approximately 200,000 files containing stock data and i am trying to aggregate these into daily files. However the times of my files start from 07:30 proceed uptil 12:59 and then go from 01:00 to 06:00. > > I want to ultimately change the times to "minutes past midnight" , i.e. 08:00 will be recorded as 480. > > I have written this code: > > for k=1: length(tmpTime) > > thisTime = tmpTime{k}; > > thisHour = str2num(thisTime(1:2)); > thisMinute = str2num(thisTime(4:5)); > > if thisHour<7; > thisHour = thisHour+12; > end; > > thisMinuteOfDay = 60*thisHour +thisMinute; > > end > > However it does not seem to be working properly as when i run the code it does not seem to change tmpTime to minutes past midnight. The problem is not in the code, but in the data structure tmpTime. If one tests your algorithm with tmpTime a simple string, it works (see below), You will need to find out how to access the data in the files. Rune %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tmpTime = '01:00'; thisTime = tmpTime; thisHour = str2num(thisTime(1:2)); thisMinute = str2num(thisTime(4:5)); if thisHour<7; thisHour = thisHour+12; end; thisMinuteOfDay = 60*thisHour +thisMinute thisMinuteOfDay = 780
From: someone on 28 Jul 2010 17:32 "Peter Smith" <fe09ae(a)mail.wbs.ac.uk> wrote in message <i2q6mp$osl$1(a)fred.mathworks.com>... > Hi all, your help would be much appreciated on this matter. I have approximately 200,000 files containing stock data and i am trying to aggregate these into daily files. However the times of my files start from 07:30 proceed uptil 12:59 and then go from 01:00 to 06:00. > > I want to ultimately change the times to "minutes past midnight" , i.e. 08:00 will be recorded as 480. > > I have written this code: > > for k=1: length(tmpTime) > > thisTime = tmpTime{k}; > > thisHour = str2num(thisTime(1:2)); > thisMinute = str2num(thisTime(4:5)); > > if thisHour<7; > thisHour = thisHour+12; > end; > > thisMinuteOfDay = 60*thisHour +thisMinute; > > end > > > However it does not seem to be working properly as when i run the code it does not seem to change tmpTime to minutes past midnight. > > Could someone please offer any reccommendations? Where does tmpTime initially get assigned? Where do you finally assign something (i.e., thisMinuteOfDay) to tmpTime? > > Many thanks
From: dpb on 28 Jul 2010 17:35 Peter Smith wrote: > Hi all, your help would be much appreciated on this matter. I have > approximately 200,000 files containing stock data and i am trying to > aggregate these into daily files. However the times of my files start > from 07:30 proceed uptil 12:59 and then go from 01:00 to 06:00. > > I want to ultimately change the times to "minutes past midnight" , i.e. > 08:00 will be recorded as 480. .... Are these files each for a given day? If so >> t=0.3125:15/(24*60):1; % some sample times in fractional hours >> thistime=datestr(t,15); % convert to hh:mm format >> minutes=datenum(thistime,15)*24*60; % the engine >> --
From: Peter Smith on 28 Jul 2010 17:39
Rune Allnor <allnor(a)tele.ntnu.no> wrote in message <b1bab0e6-50c2-4a05-a3a1-25e5e20666f6(a)u26g2000yqu.googlegroups.com>... > On 28 Jul, 23:16, "Peter Smith" <fe0...(a)mail.wbs.ac.uk> wrote: > > Hi all, your help would be much appreciated on this matter. I have approximately 200,000 files containing stock data and i am trying to aggregate these into daily files. However the times of my files start from 07:30 proceed uptil 12:59 and then go from 01:00 to 06:00. > > > > I want to ultimately change the times to "minutes past midnight" , i.e. 08:00 will be recorded as 480. > > > > I have written this code: > > > > for k=1: length(tmpTime) > > > > thisTime = tmpTime{k}; > > > > thisHour = str2num(thisTime(1:2)); > > thisMinute = str2num(thisTime(4:5)); > > > > if thisHour<7; > > thisHour = thisHour+12; > > end; > > > > thisMinuteOfDay = 60*thisHour +thisMinute; > > > > end > > > > However it does not seem to be working properly as when i run the code it does not seem to change tmpTime to minutes past midnight. > > The problem is not in the code, but in the data structure tmpTime. > If one tests your algorithm with tmpTime a simple string, it works > (see below), You will need to find out how to access the data > in the files. > > Rune > > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > tmpTime = '01:00'; > thisTime = tmpTime; > > thisHour = str2num(thisTime(1:2)); > thisMinute = str2num(thisTime(4:5)); > > > if thisHour<7; > thisHour = thisHour+12; > end; > > > thisMinuteOfDay = 60*thisHour +thisMinute > > thisMinuteOfDay = > > 780 Hi When i run the string, it only gives thisMinuteOfDay for the final time. Do i now treat tmpTime and thisMinuteOfDay for use later on in the coding? |