Compare date & time (efficiency question)

조회 수: 5 (최근 30일)
Tariq
Tariq 2012년 8월 15일
Hello everyone
Quick 2 questions:
Background: I did import lots of data using "textscan" where times and dates are crucial biases for analysis (certain actions happened at certain times on certain dates) therefor I need to pick and choose data relative to certain times & dates (i.e. if time of dataA is less than 10:00:00, do such & such). I know I can convert dates & times using “datenum” & “datestr”, then do whatever comparison I need & execute actions.
My questions are:
1) Are there any other code method that I can use to compare dates & time instead of the above codes/method?
2) In terms of computing efficiency (speed, memory, etc.), is it better if the pick & choose dates & times that I need to look at while I am importing the data using “textscan”? or shall I stick to what I am doing of importing times & dates as strings, convert them into numerical, compare & actions, then convert them into strings (if I need to)?
Thanks
Tariq

채택된 답변

per isakson
per isakson 2012년 8월 16일
편집: per isakson 2012년 8월 16일
  • "lots of data" means different things to different people. Does it fit in memory - installed RAM? RAM is cheap.
  • datenum converts to serial data number, sdn. Together with ">" and "<" sdn is good for "before" and "after" type questions. Not so good for exact comparisons (float rounding error), exactly 12:00:00 - requires a of bit care.
  • datestr is good for output and presentation. Period. Good for people to read.
  • datevec converts to - lets call it date_vec. date_vec is good for question like between 16:00 and 17:59:59 every day. Must be combined with holidays.
  • Q1: datevec, weekday, ... (Finance Toolbox should be full of useful stuff.)
  • Q2: Textfiles are painful to work with! You tell us too little about what you want to do. "computing efficiency" is not an end to itself. Use the ram and let the cpu work. Is it about GigaBytes of data at your "fingertips"? Diagram shall display before the Return key springs back? Or do you run batch jobs all night?
My recipe
  1. read textfiles once
  2. convert data and to an appropriate form. Describe a couple (or more) of typical request you will make.
  3. store it in a better place - have a look at the function, matfile. However, we want a version that is more capable with indexing. Not too many cell arrays - ideally zero.
BTW: I have started to use serial second number, ssn, which a store as integers. Stock exchange work with microseconds - or what?
  댓글 수: 1
Tariq
Tariq 2012년 8월 16일
Thanks for your answer
I am already using what you have mentioned in your answer. There are lots of things going on in my files of data & the analysis.
I will come back to you with much more details about my problem (and data) if I can't do any progress.
Thanks again
Tariq

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by