How to split vibration data into different cycles

3 views (last 30 days)
I have a vibration data with start and stop time at different timing. Every time when the machine starts, vibration occurs, so how do i split my data into different cycle(from start of vibration to end of vibration) using findpeaks(). Attached is the pic of data.
[N,m] = size(data);
t= data(:,1)
x = data(:,2)
[pks,locs] = findpeaks(x,t);
numpeaks = length(pks);
xlimit_postive = 0.2 %threshold
xlimit_negative = 0.2 %threshold
xstart = 1
for i = 1:numpeaks;
xend = locs(i);
for j = xstart:xend
split_data = x(xstart:xend, :);
split_data_t = t(xstart:xend, :);
if split_data > xlimit_postive || split_data < xlimit_negative
cycle(i) = tab(split_data_t, split_data)
end
end
xstart = xend +1
end

Accepted Answer

Daniel M
Daniel M on 4 Oct 2019
Edited: Daniel M on 4 Oct 2019
Perhaps an even easier method is to use a moving RMS calculation over a small time window. You should know what a reasonable rms value is during vibration (based on the characteristic amplitude and frequency of your system). Use movmean:
movrms = sqrt(movmean(yourvector .^ 2, nWindowLength));
where nWindowLength is the number of elements to include in your window. Then compare movrms to your estimated true rms of the vibrating signal, and classify each window as being vibration or no vibration.

More Answers (2)

Daniel M
Daniel M on 4 Oct 2019
This will depend on the characteristics of your vibration signal. Is it periodic and continuous vibration, where there is a consistent number of peaks per cycle? Or is it start-and-stop vibration and you are using findpeaks to identify clusters of time in which vibration occurs?
If you could provide some sample data, that would be a lot easier.
Otherwise, your code won't work as expected because split_data is a vector and xlimit_positive is a scalar. Think about what you are trying to evaluate. Perhaps you mean to wrap those conditions with a call to any() or all().
  1 Comment
Yong jie Ong
Yong jie Ong on 4 Oct 2019
I have attached the pic of the data, i am trying to identify cluster of time in which vibration occurs and i am not sure how am i supposed to go about doing it.

Sign in to comment.


Daniel M
Daniel M on 4 Oct 2019
So there are lots of ways to do this. Surely you could use one of the Name/Value pairs of findpeaks to help (like Threshold or MinPeakProminence or MinPeakHeight), but I think that is overkill.
A simple way would be to use a threshold to detect activity above a certain value (0.5 ought to do it, looking at your data).
vib = abs(x) > thresh
The vector vib will have a mix of zeros and ones (during vibration), followed by long sections of zeros (no vibration). Since the data is sinusoidal and therefore has many zero-crossings, it is fine to have some small number of consecutive zeros. But at a certain point, a long chain of zeros indicates no activity. You should be able to determine the minimum number of consecutive zeros necessary to character no-activity, based on the frequency of vibration and the sampling rate.
You can find the length of consecutive zeros using the following bits of code
vibPad = [1 vib 1]; % need to fix beginning and end of vib temporarily
startpoints = strfind(vibPad+'0','10');
endpoints = strfind(vibPad+'0','01');
duration = endpoints-startpoints;
Remove values in duration less than the number you determined above. Then the remaining values indicate sections of no vibration. Use startpoints and endpoints to get the indices of vibration activity and epoch your data.

Products

Community Treasure Hunt

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

Start Hunting!