MATLAB: Organising data for machine learning using buffer function

machine learningMATLAB

Hi,
I have some accelerometer data for various activities (standing, sitting, walking, walking upstairs, walking downstairs, laying), each activity coded by a number e.g. standing is 5 (see attached mat file – actid is the activity label and totalacc the accelerometer data). I’m looking to use the acc data to train a machine learning model to automatically identify the various postures/activities from accelerometer data.
To do so, I need to reorganise my accelerometer data into shorter buffers (50 samples long) of fixed length, for each posture/activity label. I have tried to use the buffer function but because the activities are all different sizes, I get zeros at the end (see "output_standing" variable in attached file as an example).
Is there a way to interpolate the data to replace my zeros with actual values? I tried the interp1 function but get NaN values – I think this is because it's the end of the signal, and ends in zeros.
Any help would be most appreciated!
Thanks!

Best Answer

There may be more efficient ways to create specific features for classification. See: Introduction to Feature Selection for a number of examples.
In any event, MATLAB has a number of feature selection algorithms that can make this easier and more reliable. (I have very limited experience with these functions, since they did not exist when I was doing classification, and I only looked through them out of curiosity.)