On Monday, November 18, 2013 12:30:12 PM UTC+13, swinnn wrote:
> I have several hundred thousands data in one column in MyData.mat file, each measurement was recorded in a specific time. I can read the time of each measurement, e.g.:
>
> datestr(MyData(10),'ddmmyyyy HH:MM:SS AM');
>
> and I got answer in 10th row the time of measurement was 10012012 12:10:04 PM
>
>
>
> Let's say I want to recall only 32 seconds out of these data, e.g. 12:21:07 til 12:21:39 PM. How can I do it?
>
>
>
> By now I found I could just recall the rows which contain these 32 seconds (12:21:0712:21:39 PM), e.g.:
>
> X=MyData(144:1220,1);
>
> but it takes lots of time to identify the rows of my interest. Is there any easier way/commend to recall the data by the time, eg. start 12:21:07, finish 12:21:39? I have tried to use logical indexing but I haven't found any solution yet.
>
>
>
> Then, my another problem is, I need to divide these 32 seconds into 2.56 seconds segments.
>
> I have tried to use C = mat2cell. It works if I specify the parameters (number of rows ), but Im looking for some other general function that divides different length of data (e.g. 32 seconds as above, 40 seconds, 35 seconds, 41 seconds etc) always in small segments of 2.56 seconds, without setting different parameters (number of rows , submatrices) each time.
>
>
>
> Sampling frequency was 100 Hz
>
>
>
> Does anybody have any idea and could help me, please?
Define your start and finish dates:
t1=datenum('10012012 12:21:07','ddmmyyyy HH:MM:SS');
t2=datenum('10012012 12:21:39','ddmmyyyy HH:MM:SS');
% Now find the data between
indx=MyData(:,1) >= t1 & MyData(:,1) <= t2;
So the data you want are in
MyData(indx,:)
And one way to find the data at particular times:
ti=t1:32/86400:t2; % There are 86400 s in a day
yi=interp1(MyData(:,1),MyData(:,2),ti);
