Filter löschen
Filter löschen

creating an interval from vector array

21 Ansichten (letzte 30 Tage)
Henry Barker
Henry Barker am 1 Sep. 2021
Kommentiert: Henry Barker am 1 Sep. 2021
I have for example a vector V = [1 2 3 4 5 6 7 8 9 10]'
I would like to create intervals in which each interval starts with the with the ending of the previous interval, Meaning interval 1: 1-2, interval 2: 2-3, interval 3: 3-4 and so on.
is there a certain command for that?

Akzeptierte Antwort

Chunru
Chunru am 1 Sep. 2021
V = [1 2 3 4 5 6 7 8 9 10]';
i = 4; % interval 4
interval = V(i:i+1)'
interval = 1×2
4 5

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 1 Sep. 2021
V = [1 2 3 4 5 6 7 8 9 10]'
V = 10×1
1 2 3 4 5 6 7 8 9 10
intervals = buffer(V,2,1,'nodelay')
intervals = 2×9
1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 10
Now take the columns of intervals.
This requires the Signal Processing Toolbox.
... and is easy enough to create on your own:
intervals = [V(1:end-1), V(2:end)].'
intervals = 2×9
1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 10
  1 Kommentar
Henry Barker
Henry Barker am 1 Sep. 2021
perfect thanks a lot, thats exactly what I wanted

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by