Analyzing Timestamp array data

1 view (last 30 days)
Hussam Ibrahim
Hussam Ibrahim on 4 Dec 2017
Answered: KSSV on 4 Dec 2017
I have an array of 1x2 million timestamps, and I want to analyze this data by better viewing them. I want to have a slider (say every 0.001 seconds), and check how many stamps fall in each 0.001 second range.
e.g. dataArray = [0.0001 0.0005 0.0009 0.001 0.0012 0.0018] resultArray = [4 2] because first 4 elements are between 0 and 0.001, and last 2 are between 0.001 and 0.002. I am also trying to make this as fast as possible since I have million data points.
Best,

Answers (1)

KSSV
KSSV on 4 Dec 2017
dataArray = [0.0001 0.0005 0.0009 0.001 0.0012 0.0018] ;
t0 = 0. ; t1 = 0.001 ;
dt = 0.001 ;
idx = cell(2,1) ;
for i = 1:2
idx{i} = find(dataArray > t0 & dataArray <= t1) ;
t0 = t0+dt ; t1 = t1+dt ;
end
iwant = cellfun(@nnz,idx) ;

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!