Selecting rows related with specfic measurement time

I have data from a sensor, data were recording for five days non stop. How to select specific rows, related with the certain time, e.g. 11-09-2013 11:20:00 - 11:21:49 PM ? Then, how to divide the obtained data into equal segments 2.56 seconds each? Help me please

Answers (2)

Hint: Use datenum():
>> datenum('11-09-2013 11:20:00')
ans =
735547.472222222

1 Comment

I have tried datenum,
start= datenum('11-09-2013 11:20:00 PM'); stop = datenum ('11-09-2013 11:21:49 PM')
but when i do : x=find(data >= start & data <= stop);
i get empty matrix..

Sign in to comment.

You need to specify the format of your date
datenum('11-09-2013 11:20:00 PM','dd-mm-yyyy HH:MM:SS AM')

5 Comments

Thanks. But I still get 'empty matrix'.. I dont know whats wrong. I am sure there are data between 11:20:00 PM and 11:21:49 PM because I can see the measurements with the time in this range (by using datestr(data(numer of row) )
Post a sample of your data
  • x y z
  • -0.0224403887987136 -0.00425944756716489 -0.0343598052859306
  • -0.0140440063551068 0.00314281554892659 0.0191326308995485
  • 0.0151008730754256 -0.0140217468142509 0.0528425388038158
  • 0.00474679144099354 -0.0251027867197990 0.00359923788346350
  • -0.0112735414877533 -0.00467106094583869 0.0114241288974881
  • 0.00925841461867094 0.0121382083743810 0.0169971082359552
  • ..............I have several hundreds of rows like this
load('data.mat');
start = datenum('11-09-2013 11:20:00 PM', 'dd-mm-yyyy HH:MM:SS AM') / 86400
stop = datenum('11-09-2013 11:21:49 PM', 'dd-mm-yyyy HH:MM:SS AM') / 86400
x = find(data >= start & data <= stop);
i get: x= Empty matrix: 0-by-1
And no matter what time range do i chose, always i get same number for start and stop, e.g.
start =
8.5120
stop =
8.5120
Check your data
celldisp(arrayfun(@(x) datestr(x, 'dd-mm-yyyy HH:MM:SS AM'),data*86400,'un',0))
??? Error using ==> dateformverify at 28 DATESTR failed converting date number to date vector.
Error in ==> datestr at 197 S = dateformverify(dtnumber, dateformstr, islocal);
Error in ==> @(x)datestr(x,'dd-mm-yyyy HH:MM:SS AM')
Caused by: Error using ==> datevecmx Date number out of range.

Sign in to comment.

Categories

Asked:

on 20 Nov 2013

Commented:

on 21 Nov 2013

Community Treasure Hunt

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

Start Hunting!