finding the duration of a sequence of data
7 views (last 30 days)
Show older comments
Commented: sarmad m on 7 Jul 2017
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 ?
Andy on 6 Jul 2017
positive = (data>0); % Identifies when the head is to the right.
pos_count = sum(positive); % gives you the number of measurements.
If you have the logging frequency it is easy to calculate time.
The similar code can be used for determining left movement. Instead of using data>0 use another number to give a bit of tolerance on what constitutes looking ahead.
Andrei Bobrov on 6 Jul 2017
d = csvread('case2.csv');
d1 = d(d ~= 0);
t = d1 > 0;
tt = diff([1;t(:)]) ~= 0;
out = accumarray(cumsum(tt),d1);
Find more on Pulsed Waveforms 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!