필터 지우기
필터 지우기

how to generate overlapping series

조회 수: 4 (최근 30일)
Ali Asghar
Ali Asghar 2020년 2월 1일
댓글: Ali Asghar 2020년 2월 4일
Dear
data of 30000x1.
want to make first packet of 2000 values
but in 2nd packet last 500 values from packet 1 repeat, means 2nd packet value start from 1500 and end at 3500.
3rd packet start at 3000 and end at 5000
till end of 30000.
How can i do it?

답변 (1개)

Ioannis Andreou
Ioannis Andreou 2020년 2월 1일
Try this
packages = nan(19, 2000);
for i = 1:19
packages(i,:) = data((i-1)*1500+1: i*1500+500);
end
However there will be a few data left, less than 2000 though, so you cant fill a new package with them
  댓글 수: 1
Ali Asghar
Ali Asghar 2020년 2월 4일
Dear
I have two codes for overlapping windows, once yours and second code from other.
I run two codes on data and check result.
both code give right answer for 1st window only but give different answer for 2nd etc wondows which start from 1500 and end at 1500.
2 CODE
function segments_cell = overlap_window_segmentation(signal,windowSize,overlap,fs,rowNumber,filteredOrRaw)
%filteredOrRaw must be 1 for raw data and must be other numbers for filtered data.
colors=['r','g'];
%L=length(signal);
sz=size(signal);
if(sz(2)==1)
signal=signal';
end
sz=size(signal);
numberOfSegmentsEachRow=floor(sz(2)/(windowSize-overlap));
remaindar = mod(sz(2),(windowSize-overlap));
if remaindar < overlap
numberOfSegmentsEachRow=numberOfSegmentsEachRow-1;
end
save('numberOfSegmentsEachRow.mat','numberOfSegmentsEachRow');
total_number_of_segments=numberOfSegmentsEachRow*sz(1);
%segments = NET.createArray('System.Double[]',total_number_of_segments);
segments = zeros(total_number_of_segments,windowSize);
maxSignal= max(signal(rowNumber,:));
t=(1:length(signal(rowNumber,:)))/fs;
figure
plot(t,signal(rowNumber,:));hold on,
i=0;
j=1;
hight=[maxSignal 0.8*maxSignal];
for k=1:sz(1)
start=1;
L=length(signal(k,:));
while(start+windowSize-1 <= L && j <= total_number_of_segments)
%segments(j)=signal(k,start:start+windowSize-1);
segments(j,:)=signal(k,start:start+windowSize-1);
if(k==1)
plot([start start]/fs ,[hight(i+1) -0.5*maxSignal],colors(i+1));hold on,
plot([start+windowSize-1 start+windowSize-1]/fs ,[hight(i+1) -0.5*maxSignal],colors(i+1));hold on,
plot([start start+windowSize-1]/fs, [hight(i+1) hight(i+1)],colors(i+1));
end
start=start+windowSize-1-overlap;
i=~i;
j=j+1;
end
end
if(filteredOrRaw==1)
title('Overlap window segmentation for raw data');
else
title('Overlap window segmentation for filtered data');
end
xlabel('Time (s)');
ylabel('Amplituse');
%segments_cell=cell(segments);
segments_cell=segments;

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

카테고리

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

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by