Create a sliding window
Ältere Kommentare anzeigen
Hey guys, thanks in advance
I have this code, that gives me a vector, samples , that has 10 000 000 values( a lot). I wanted to divide this vector in 500 000 samples do all the processing code I have , and choose the next 500 000 samples, with a sliding window, till i finished all the samples.
So first iteration I wanted samples(1:500 000), 2nd iteration(501000: 1000000), etc...
But with a sliding window function, can I do that
Thank you
Akzeptierte Antwort
Weitere Antworten (1)
matrix=reshape(vector,5e5,[])
This gives a matrix whose i-th window is matrix(:,i). How best to process that, though, depends on the specifics of the sliding window operation.
2 Kommentare
Miguel Albuquerque
am 2 Jul. 2022
Matt J
am 2 Jul. 2022
It can be faster. For example, if you are calculating the mean over each window,
mean( reshape(vector,5e5,[]) )
will be faster than looping.
Kategorien
Mehr zu Logical 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!