finding the duration of a sequence of data

조회 수: 2 (최근 30일)
sarmad m
sarmad m 2017년 7월 6일
댓글: sarmad m 2017년 7월 7일
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 ?

답변 (2개)

Andy
Andy 2017년 7월 6일
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.
  댓글 수: 1
sarmad m
sarmad m 2017년 7월 6일
Thanks ,but how the duration of each sequence can be found as shown in the image ?

댓글을 달려면 로그인하십시오.


Andrei Bobrov
Andrei Bobrov 2017년 7월 6일
d = csvread('case2.csv');
d1 = d(d ~= 0);
t = d1 > 0;
tt = diff([1;t(:)]) ~= 0;
out = accumarray(cumsum(tt),d1);
  댓글 수: 3
Andrei Bobrov
Andrei Bobrov 2017년 7월 6일
another variant
t = d ~= 0;
d1 = d(t);
t1 = d1 > 0;
tt = [true;diff(t1)~=0];
ii = cumsum(tt);
out = accumarray(ii,1).*sign(d1(tt));
sarmad m
sarmad m 2017년 7월 7일
the plot below shows a signal and (out) plot . out values are :
-25 122 -130 25 -7 138 -17 37 -53 58 -46 so do they represent the duration of each sequence ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by