# how generating evenly spaced vectors with overlap?

2 ビュー (過去 30 日間)
pietro 2014 年 6 月 26 日
コメント済み: pietro 2014 年 6 月 27 日
Hi all,
I need to generate evenly spaced vectors with overlap. How can I do it? Here an example:
Input: [0 5 10 15 20];
Output: [0 5, 4 10,9,15,20];
I know they are not even, but also like that is fine.
Thanks cheers
##### 3 件のコメント表示非表示 2 件の古いコメント
pietro 2014 年 6 月 26 日
By istance I want to create 4 slices of a 20 seconds long time history with an overlap of 0%. So I do:
SeparationPoints=linspace(0,20,5);
and I get: [0 5 10 15 20] and my signal slices are: [0 5; 5 10;10 15;15 20];
with a 5% overlap, that it will be: 20*5/100=1 so my signal slices will be something like [0 5; 4 10 ;9 15; 14 20]; The 5% of overlapping is the difference between the end of the slice and the beginning of the following one.
Is it clearer now?

サインインしてコメントする。

### 採用された回答

Joseph Cheng 2014 年 6 月 26 日

Starting with the linspace above that people suggested you can get the over lap you by doing this:
input = [0 5 10 15 20];
overlap = 5; % percent
overlap = input(end)*(overlap/100);
output = [input(1:end-1)'-overlap input(2:end)']
output(output<0) = 0;
disp(output)
##### 1 件のコメント表示非表示 なし
pietro 2014 年 6 月 27 日
Thanks!

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!

Translated by