Split vector to sub vectors of equal size

I have a lond vector of measurements taken every 15 mins for 3 months and want to seperate this in measurements of each day
What should I use?

Answers (1)

If the sampling times are uniform (constant sampling intervals between the observations) use the Signal Processing Toolbox buffer function.
v = randn(1,4*24*2) % Two Days' Measurements
v = 1×192
-1.7302 0.5357 0.2997 -0.6569 -3.1447 -0.7573 1.5844 -0.9395 0.3383 2.1405 0.6417 0.2237 -0.0870 0.4797 1.7342 -0.1422 0.5905 1.5697 -1.8996 -0.3106 -0.1646 0.1758 0.5955 1.0822 1.1760 0.4522 0.0625 -0.0768 0.7376 0.1185
rowLengths = 24*60/15;
vdays = buffer(v, rowLengths)
vdays = 96×2
-1.7302 0.4966 0.5357 1.3182 0.2997 -0.2318 -0.6569 -1.8533 -3.1447 -0.2428 -0.7573 0.0566 1.5844 0.7537 -0.9395 0.0877 0.3383 -0.2104 2.1405 0.4684
The reshape function is also an option, however buffer is easier to use.
I have a simple emulation of the buffer function (does not do everything) I can post if theSignal Processing Toolbox is not available.
.

Categories

Find more on Sparse Matrices in Help Center and File Exchange

Asked:

on 11 Dec 2021

Answered:

on 11 Dec 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!