Amplitude detection in time series data

18 views (last 30 days)
I have a time seriese of data recorded from gyroscope I need to detect the specific time of the large Amplitud change ? I can detected manualy but I want automatic detection
note you can see the attachment

Accepted Answer

Star Strider
Star Strider on 18 Sep 2021
Edited: Star Strider on 18 Sep 2021
There are at least two functions you could experiment with, those being findchangepts and ischange.
EDIT — (18 Sep 2021 at 13:56)
Another option that occurred to me is to use the envelope function first, and then use findchangepts and ischange on the envelope results, instead of the original signal.
  1 Comment
Star Strider
Star Strider on 19 Sep 2021
Part of this was relatively straightforward because the Signal Processing Toolbox has functions that are useful for these sorts of problems. The first peak was not at all straightforward.
T1 = readtable('', 'VariableNamingRule','preserve')
T1 = 949×4 table
Time Acceleration (X) Acceleration (Y) Acceleration (Z) __________ ________________ ________________ ________________ 1.6319e+09 0.10965 -0.33752 -0.91861 1.6319e+09 0.13879 -0.32091 -0.97334 1.6319e+09 0.13879 -0.32091 -0.97334 1.6319e+09 0.090439 -0.28499 -0.98012 1.6319e+09 0.094757 -0.29201 -0.90482 1.6319e+09 0.094757 -0.29201 -0.90482 1.6319e+09 0.099686 -0.29663 -0.92142 1.6319e+09 0.085175 -0.28722 -0.95512 1.6319e+09 0.085175 -0.28722 -0.95512 1.6319e+09 0.087875 -0.2925 -0.95572 1.6319e+09 0.081604 -0.28847 -0.95352 1.6319e+09 0.076187 -0.28435 -0.94444 1.6319e+09 0.064056 -0.28123 -0.93147 1.6319e+09 0.061493 -0.28233 -0.93028 1.6319e+09 0.061996 -0.28271 -0.93291 1.6319e+09 0.060394 -0.28033 -0.9406
Magnitude = vecnorm(T1{:,2:4},2,2);
MagEnv = envelope(Magnitude, 11, 'peak');
[pw,firstx,lastx] = pulsewidth(MagEnv);
plot(T1.Time, Magnitude)
hold on
plot(T1.Time, MagEnv, '-r')
plot(T1.Time(round(firstx)), MagEnv(round(firstx)), '>g', 'MarkerFaceColor','g')
plot(T1.Time(round(lastx)), MagEnv(round(lastx)), '<r', 'MarkerFaceColor','r')
x = T1.Time;
y = MagEnv - median(MagEnv);
[ymx,idx] = findpeaks(y, 'MinPeakDistance',100, 'NPeaks',1)
ymx = 0.0969
idx = 61
% x(idx)
hafmax = ymx*0.1;
for k = 1:numel(hafmax)
idxrng1 = find(y(1:idx(k))<hafmax(k), 1, 'last');
idxrng2 = find(y(idx(k):numel(x))<hafmax(k),1,'first')+idx(k);
xm(k,1) = interp1(y(idxrng1+(-3:3)), x(idxrng1+(-3:3)), hafmax(k));
xm(k,2) = interp1(y(idxrng2+(-3:3)), x(idxrng2+(-3:3)), hafmax(k));
plot(xm(1), hafmax+median(MagEnv), '>g', 'MarkerFaceColor','g')
plot(xm(2), hafmax+median(MagEnv), '<r', 'MarkerFaceColor','r')
hold off
The blue line is the magnitude signal, the red line is the envelope, the green markers are the beginning of the pulses and the red markers are the ends of the pulses.
The last four peaks can easily be identified with the pulsewidth function. The first peak is difficult to identify because of the offset, and cannot be used with it, so I went with some legacy code that I use for these sorts of problems. The round values of the ‘firstx’ and ‘lastx’ vectors (they must be integers to be used as indices) identify the indices of the respective parts of the identified ‘pulses’. The ‘xm’ values are the actual times, not the indices.
Experiment to get the results you want.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 18 Sep 2021
Edited: Image Analyst on 18 Sep 2021
You could probably use stdfilt() or movstd(). Try different window widths and plot the output.
Or try thresholding and labeling. Search for questions on finding words or silence in audio waveforms - there has been a lot of questions regarding that. It's a similar kind of thing.
Attach the data in a .mat or .txt or .csv file if you need more help.

Community Treasure Hunt

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

Start Hunting!