I want to write a sliding window algorithm for use in activity recognition.
The training data is <1xN> so I'm thinking I just need to take (say window_size=3
) the window_size
of data and train that. I also later want to use this algorithm on a matrix
.
I'm new to matlab so i need any advice/directions on how to implement this correctly.
The short answer:
idx
will be a matrix of size nwind-by-K where K is the number of sliding windows (ie each column contains the indices of one sliding window).Note that in the code above, if the last window's length is less than the desired one, it is dropped. Also the sliding windows are non-overlapping.
An example to illustrate:
EDIT:
For overlapping windows, let:
then the above is simply changed to:
An example to show the result: