How can I split an array into equal overlapping sub-arrays?
Ältere Kommentare anzeigen
How can I split an array into equal overlapping sub-arrays?
Simple example where the array divides evenly without any need for overlapping
ArrayX = 1:160;
ArraySplitSize = 4
Result is
1:40, 40:80, 80:120, 120:160
Example where overlapping is needed. I want to keep full size of the array and not cut off anything at the end.
ArrayX = 1:100;
Subarray = 40;
ArraySplitSize = 3;
Result is 1:40, 30:70, 60:100
3 Kommentare
Image Analyst
am 10 Apr. 2020
Kelly Kearney
am 10 Apr. 2020
Also, what's the rule you used to decide which of the overlapping blocks get shorted when the array isn't evenly divisible? E.g. in your latter example, you indicate subarrays of length 40, 41, and 41. Also, in your first example, you listed values with overlaps; I assume that should be 1:40, 41:80, 81:120, and 121:160, right?
mark palmer
am 10 Apr. 2020
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Special Functions finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!