Identify Zerocrossing Indices near to the peak of the other signal matlab
Show older comments
Hi all, 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
Any help in this regard is highly appreciated.
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')
Accepted Answer
More Answers (1)
KSSV
on 27 May 2022
0 votes
Multiple options:
- Use knnsearch
- Use interp1
- Use InterX: https://in.mathworks.com/matlabcentral/fileexchange/22441-curve-intersections
I would suggest to use third option.
1 Comment
Ganesh Naik
on 27 May 2022
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





