-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsplit_vector.m
21 lines (16 loc) · 896 Bytes
/
split_vector.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function splitted_result = split_vector(input_signal,split_length,overlapping_length,fs)
% Input_signal is the row vector which is needed to be splited. Split_length
% and overlapping_length is the lenght of the windows in milliseconds
% Every column of the output matrix corresponds to a chunk of the vector
% Transform milliseconds to samples
Ts = 1/fs;
split_length_samples = fix(split_length*0.001 / Ts);
overlapping_length_samples = fix(overlapping_length*0.001 / Ts);
clip_length=fix(size(input_signal,1)/split_length_samples)*split_length_samples;
splitted_result=zeros(split_length_samples,clip_length/split_length_samples);
index=1;
for i=1:split_length_samples-overlapping_length_samples:clip_length-split_length_samples
splitted_result(:,index)=input_signal(i:i+split_length_samples-1,1);
index=index+1;
end
end