Grouping using for loops (signal processing)
이전 댓글 표시
I am working with a signal data that consist of consecutive dips as shown below. I am only interested in the portion of the signal that lies below a certain point d (the red line). I am trying to write a code which sorts the contents of each dip into one separate group.

And here is the grouping that I need:

For instance, the following code is one of my attempts which didn't work. It generates 310 groups instead of the desired 12 groups.
k=0; % Group number
for i = 1 : length(signal)
if signal(i) < d
k=k+1;
while signal(i) < d
NewSignal(i, k) = signal(i);
i = i + 1;
end
end
end
Any explanations or suggestions would be greatly appreciated.
P. S. I've included an attachement of my data which can be accessed as follows:
M = csvread('DS0007.csv');
time = M(:,1)*1.00e-03;
waveform = M(:,2)*2.00e-01;
waveform = sgolayfilt(waveform,9,21);
댓글 수: 3
dpb
2019년 4월 26일
Attach a data file so folks have something to work with.
My suggestion/starting point would be to use findpeaks to locate each peak and then pick the data from those locations either side the peak to the threshold.
Sordin
2019년 4월 27일
dpb
2019년 4월 27일
You're already using it...
>> which sgolayfilt
C:\ML_R2017\toolbox\signal\signal\sgolayfilt.m
>>
But, it appears the signal is noise-free enough that it shouldn't be hard to find the locations with a much larger difference between ordinal positions than the next point once you've separated out those less than the threshold.
Use find to return the positions from the logical vector
ix=find(waveform<d);
peakarray=waveform(ix);
dx=diff(ix);
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Spectral Estimation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!