How can I extract a signal between zero up-crossings
4 views (last 30 days)
Show older comments
I have a time series of wave elevation data (as shown in fig. below). The length of the time series is 34121x1.
I want to extract the waves between two zero up-crossings. I have attached a picture to illustrate what I mean by zero up-crossings.
I found the following code online that just identifies the highest peak and extracts values before and after it. This code was not helpful as it only gave half cycle of the wave. I need to extract all the major waves between zero up-crossings.
load('Signal.mat');
[pk,ipk]=max(s); % largest peak, location
BL=0; % set baseline level
ilo=find(s(1:ipk)<=BL,1,'last'); % lower boundary location
ihi=find(s(ipk:end)<=BL,1,'first')+ipk-1; % upper boundary location
pkS=s(ilo:ihi);
0 Comments
Accepted Answer
Fabio Freschi
on 15 Oct 2019
Edited: Fabio Freschi
on 15 Oct 2019
You can take a look at this post, where zero crossing is discussed in details
Using the same reasoning, the identification of zero up-cross can be done with this code
% the signal
x = linspace(0,10*pi,100);
y = sin(x)+2*sin(3*x+pi/7);
% find approx up-cross point (index)
idx1 = find(y <= 0 & circshift(y,-1) >= 0);
% next point
idx2 = idx1+1;
% fix for last point
idx2(idx2 > length(x)) = length(x)-1;
% linear approximation
x0 = -y(idx1).*(x(idx2)-x(idx1))./(y(idx2)-y(idx1))+x(idx1);
y0 = 0;
% plot
figure,hold on, grid on
plot(x,y)
plot(x(idx1),y(idx1),'o')
plot(x0,y0,'*');
legend('signal','approx','interpolated')
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!