Is there a function like movsum which simply gets the values in a given sliding window rather than summing them?
Afficher commentaires plus anciens
If I have a sequence
x = [1 2 3 4 5 6 7 8 9 10];
What is the most efficient way to get sub-vectors in a sliding window, i.e., if the window is of length 2;
[1 2]
[2 3]
[3 4]
[4 6]
etc.
I ask this because I need get these values at multiple different window lengths.
Thank you in advance.
Réponse acceptée
Plus de réponses (2)
b=1:10;
a=b;
n=5;%window size
for k=1:n-1
a=[a;circshift(b,-k)];
end
a=a';
a=a(1:length(b)-n+1,:)
Bora Eryilmaz
le 4 Avr 2023
Modifié(e) : Bora Eryilmaz
le 4 Avr 2023
If you have access to the Predictive Maintenance Toolbox, you can use the phaseSpaceReconstruction command:
x = [1 2 3 4 5 6 7 8 9 10];
sz = 2;
y = phaseSpaceReconstruction(x, 1, sz)
sz = 4;
y = phaseSpaceReconstruction(x, 1, sz)
Catégories
En savoir plus sur Programming 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!