How can I extract a signal between zero up-crossings
3 次查看(过去 30 天)
显示 更早的评论
I have a time series of wave elevation data (as shown in fig. below). The length of the time series is 34121x1.
![untitled.bmp](https://www.mathworks.com/matlabcentral/answers/uploaded_files/242837/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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/242838/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);
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!