# finding the duration of a sequence of data

I need to find the duration of a sequence of data values that represents head yaw

movements .where the positive values are head looking to right and negative values

are head looking to left .the below signal has different duration of looking right

and left. How can I find these duration ?

• use condition (greater than or less than) in matlab to find the time values indices greater than zero and less than. For greater than, take the indices arrange into different classes bases on the connection (sequence). Find the difference of each class between max and min which will provide duration for each class (connected sequence). Repeat the same for less than – Zeeshan Jul 6 '17 at 14:32
• you can also filter it before to have smooth response, if it does not destroys your information – Zeeshan Jul 6 '17 at 14:33
• I would threshold the time-series to get only 1, 0 and -1 then it's simply a matter of counting blocks of 1s' / -1s' duration – Florent Jul 7 '17 at 4:30
• I have filtered the signal using SG ang got this : ![filtered signal ](ibb.co/iKaE7v). Now if I separate it for less than and larger than 0 how can I find the duration of each sequenced values ? – amir Jul 7 '17 at 8:15
• Well considering your data to be uniformly sampled, the duration of a sequence is your sampling period times the number of elements in your sequence. For the number of elements it depends on where you implement your algorithm but it shouldn't be too difficult, right? – Florent Jul 8 '17 at 16:49