dividing signal into subsets

I have about 5 hours of the acceleration data for a particular user ( the collected data is real life data, which means I don't know what the user is doing at a particular time).
the dataset contains the time stamp in the first column and the acceleration data of 3 axes (X, Y, and Y) in the second, third, fourth columns respectively.
Time Stamp X Data Y Data Z Data
I would like to divide the data based on the user's activities (which is called Activity Recognition in order to make it easy for the classification).
For example, if the user is walking, extract his signal and store it in an array, if he is typing, the typing data will be extracted and store in another array, and so on. Hence, N number of arrays will be created, each will contain data of specific activity.
by the way, it doesn't matter what is the activity, it is more useful to extract the user's pattern for each part of the original signal ( pattern means, the user's signal looks consistent).
here is an example of the original signal for each axis
As we can see, the original signal looks very noisy ( as the user do more than one activity at the same day) therefore, I'd like to divide the signal into subsets based on the user's activity.
Note, the highlighted part in attached pics was just an example of walking data from the original signal. I know it's walking data because as we can see it contains repetitive peaks that normally generated when the user is walking
I have attached a sample of my data
really appreciate any help.
Regards.

Answers (2)

Image Analyst
Image Analyst on 5 May 2017
You forgot to attach any data so people can't try anything. I'd be tempted to filter the data with movstd() and then threshold. The parts you indicated should have low standard deviation. You'll need to play around with the window size parameter to find out what window size is best for your particular data.

1 Comment

Dear Image Analyst,
I have attached a sample of my data, right now I don't have a clue how to get this done. could you please help me with that?

Sign in to comment.

Image Analyst
Image Analyst on 5 May 2017
See attached demo.

5 Comments

dear sir, thank you very much for your help!!
I tried to run the code but I have these errors!
Undefined function or variable 'xticks'
Undefined function or variable 'movmean'. I am using R2015a.
and are you storing the extracted signal in a particular variable, please?
You're two years behind. Can you upgrade? If not, why not? Anyway, you can use conv() instead of movmean(), and stdfilt() instead of movstd(). See attached.
Extracted signal is of course:
extractedSignal = xAccel(startingIndex : startingIndex);
Standard MATLAB stuff.
Hi again, I can't upgrade unfortunately because this will require changing in my previous code!
I really appreciate your help! first, I still have the error
Undefined function or variable 'xticks'.
second: I guess you misunderstood what i'm looking for!
the collected data is real life data, and i'm looking to detect the user's movement based on his activities (such as if he is walking, I need to automatically extract his signal and store it in an array, if he is typing another array will be created and contains the typing data and so on, hence at the end I will have N number of arrays each contains the data of specific activity).
from your attached figures, seems that you are smoothing the original signal? and I don't want to smooth the signal now! I'd like to divide the whole signal into groups ( each group, contain data of specific activity).
the highlighted part in my attached pic was just an example of walking data from the original signal. I know it's walking data because as you can see it contains repetitive peaks that normally generated when the user is walking
I hope this make sense!
again many thanks for your help and contribution
Most of your code should still work with the new version, unless you've used some function deprecated long ago. You can't stay stuck in the past forever so I'd encourage you to upgrade.
You don't need xticks() so you can just remove it.
You say "I don't want to smooth the signal now!" But that's the way to identify the sections you want. To extract your original signal, save it then extract it
xAccel = xAccel(1 : lastIndex+1);
originalSignal = xAccel; % Save original, non smoothed, non filtered signal.
% Smooth it.
kernel = ones(1001, 1) / 1001;
xAccel = conv(xAccel, kernel, 'same');
Then at the end, extract it
extractedSignal = originalSignal(startingIndex : startingIndex);
Dear Sir, thanks for your help. again i guess you still misunderstood the idea! first: the smothed data become flat! and i want to keep the pattern of the extracted part as it is !
Second: the output of this line of code is only one value? while I expect to get many rows and 4 columns ( time stamp, X, Y, Z)
extractedSignal = xAccel(startingIndex : startingIndex);

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!