0
votes

I have two signals (data attached) , for first signal I plot the peaks of the signal and for the second one I find zero crossings of the signal. My aim is to find the zero crossing indices (start and stop) closer to the peak of the first signal. In this example (please refer to the figure), peak for the first signal is around 4.567 and the zerocrossings (closest ones) are closer to 4.564 and 4.571 respectively. I would like to get these indices (start and stop) for the signal with all the peak points. For your reference, I have added data, code for peak and zerocrossing and also figure. https://www.dropbox.com/s/i8s52no5ivdo6gm/data.mat?dl=0 enter image description here

load Data.mat;
t=1:length(Data(:,1));
[pk,lk] = findpeaks(Data(:,1),t,'MinPeakProminence',200);
ax1=subplot(211); 
plot(t,Data(:,1),lk,pk,'o')
                                                   
y = Data(:,2);                                                        
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0);                    
zx = zci(y);  % Approximate Zero-Crossing Indices
figure(1); 
ax2=subplot(212)
plot(t, y, '-r')
hold on
plot(t(zx), y(zx), 'bp'); hold on;
% plot(t,Pepi);
hold off
grid
legend('Signal', 'Approximate Zero-Crossings')
linkaxes([ax1 ax2],'x')