Grouping using for loops (signal processing)
2 次查看（过去 30 天）
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
while signal(i) < d
NewSignal(i, k) = signal(i);
i = i + 1;
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);