How can I split an array into equal overlapping sub-arrays?
Afficher commentaires plus anciens
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 commentaires
Image Analyst
le 10 Avr 2020
Kelly Kearney
le 10 Avr 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
le 10 Avr 2020
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Special Functions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!