How can I extract a signal between zero up-crossings

조회 수: 6 (최근 30일)
maruljay
maruljay 2019년 10월 15일
편집: Fabio Freschi 2019년 10월 15일
I have a time series of wave elevation data (as shown in fig. below). The length of the time series is 34121x1.
untitled.bmp
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.
8462406809.gif
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);

채택된 답변

Fabio Freschi
Fabio Freschi 2019년 10월 15일
편집: Fabio Freschi 2019년 10월 15일
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개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by