MATLAB: How to cut the signal

csvcutremovesignal

Dear All, I have waveform data in csv file in 'X' and 'Y' axis, the plot is on the figure attached. I want to remove the unneeded signal marked by arrows sign in order to get complete waveform signal. Is there any advice/better algorithm to remove the signal automatically ? My idea is to track the data in a loop then find the '0' value in the 'Y' axis and delete the rows before. Best regards.

Best Answer

How about if you simply find the first and last time that y is negative?
index1 = find(y<0, 1, 'first'); % Find left index
index2 = find(y < 0, 1, 'last'); % Find right index.
% Now crop signal
yCropped = y(index1:index2);