필터 지우기
필터 지우기

sliding window algorithm for time-series data

조회 수: 48 (최근 30일)
Sameer Sayyad
Sameer Sayyad 2021년 5월 20일
댓글: Alyaa Ghazi 2024년 4월 20일
I have sample data and sampling frequency . Sample data points are 27900 and sampling frequency is 600 hz . I want to apply slidding window concept for my data. I want divide all data into set of 5 sec each with overlap of 4 sec. (i.e. 0-5, 1-6, 2-7, etc.). Please help me to apply slidding window concept.

채택된 답변

Mathieu NOE
Mathieu NOE 2021년 5월 20일
HELLO
see demo below - second section implement a overlap method
all the best
clc
clearvars
% dummy data
data = rand(320,3); % data must be column oriented (number of rows = number of samples)
buffer = 25; % nb of samples for averaging
%% zero overlap averaging (unweighted)
[m,n] = size(data);
for ci=1:fix(m/buffer)
start_index = 1+(ci-1)*buffer;
stop_index = min(start_index+ buffer-1,m);
time_index(ci) = round((start_index+stop_index)/2); % time index expressed as sample unit (dt = 1 in this simulation)
avg_data(ci,:) =mean(data(start_index:stop_index,:)); %
end
figure(1),
plot(time_index,avg_data,'+-');
% return
%% averaging with overlap
clearvars
% dummy data
data = rand(320,3);
buffer = 25; % nb of samples in one buffer (buffer size)
overlap = 10; % overlap expressed in samples
%%%% main loop %%%%
[m,n] = size(data);
shift = buffer-overlap; % nb of samples between 2 contiguous buffers
for ci=1:fix((m-buffer)/shift +1)
start_index = 1+(ci-1)*shift;
stop_index = min(start_index+ buffer-1,m);
time_index(ci) = round((start_index+stop_index)/2); % time index expressed as sample unit (dt = 1 in this simulation)
avg_data(ci,:) = mean(data(start_index:stop_index,:)); %
end
figure(2),
plot(time_index,avg_data,'+-');
  댓글 수: 8
Sameer Sayyad
Sameer Sayyad 2021년 5월 20일
Okay. Thank you so much sir.
Alyaa Ghazi
Alyaa Ghazi 2024년 4월 20일
This was very helpfull to me also. Thanks alot.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by