How to create sliding window
I know this question was asked before, but I could not find a solution that suits my problem. The code should do the following:
Data is recorded and saved in a variable "data", which is a 3D array (e.g.: data = 27 x 15 x 74635). Here, I only need column 3 (c = 74635) from data. Each number (e.g. 1, 2, 3,...) in column 3 contains a 2D array.
The code should save each number (from column 3) in a single variable “package”.
It should continue saving each following number as a "package", until a predefined number of packages (which are set by variable “x”) is reached.
I was thinking to apply a sliding window approach, if it makes sense, but I have no idea how to do so. Since I am dealing with many data, I was thinking to preallocate the array. So here is what I got until now:
Data = zeros(size(Recording.data,3)); % preallocating the array to the size of my amount of data
for i = 1:size(Recording.data,3) Data(:,:,i = [Data,squeeze(Recording.data(:,:,i))];
How can I apply a sliding window "algorithm"/approach to my code?
5 Comments
Accepted Answer
2 Comments
More Answers (0)
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!