Hello, I need help extracting the two indices of marked with two red crosses on the figure below. I need those two indices to extract the first tall wave of the signal outlined in red. The two red crosses are points that intersect with zero, but I can't use find(y == 0) since there is no point exactly at 0.

I need to extract these two points since they make up one period of the tall signal. I have multiple signals like this, but all with different peak locations and amplitudes. However, all the other signals also have the tallest wave as the first signal.

So far, I've tried this method:

[~, loc] = findpeaks(signal, 'MinPeakHeight', 0.2);

firstpeak = loc(1);

signal_inverse = -signal;

[~, loc] = findpeaks(signal, 'MinPeakHeight', 0.2);

secondpeak = loc(1);

pad = (secondpeak - firstpeak) / 2;

signal = signal(firstpeak-pad:secondpeak+pad);

This, however, assumes that all waves are perfect and don't catch any noise.

A new and better approach I'm thinking of is using the Zero-Crossing detection algorithm. I've already seen many on MATLAB community, but I don't seem to be applying those into my signals properly.

Any help would be appreciated. Thank you!!

## 3 Comments

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/597712-i-want-to-implement-an-end-point-detection-for-a-tall-spike-in-a-sound-signal#comment_1019509

⋮## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/597712-i-want-to-implement-an-end-point-detection-for-a-tall-spike-in-a-sound-signal#comment_1019509

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/597712-i-want-to-implement-an-end-point-detection-for-a-tall-spike-in-a-sound-signal#comment_1019692

⋮## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/597712-i-want-to-implement-an-end-point-detection-for-a-tall-spike-in-a-sound-signal#comment_1019692

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/597712-i-want-to-implement-an-end-point-detection-for-a-tall-spike-in-a-sound-signal#comment_1022131

⋮## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/597712-i-want-to-implement-an-end-point-detection-for-a-tall-spike-in-a-sound-signal#comment_1022131

Sign in to comment.