finding the exact points of Zero crossing using interpolation method

조회 수: 16 (최근 30일)
Jimmy cho
Jimmy cho 2020년 10월 19일
댓글: Star Strider 2020년 10월 19일
Hi guys,
Im implementing in matlab zero crossing points to my signal , frequency sampling is 2048Khz.
my matlab code that Im using is:
y= % * my signal input* it's like sinusoidal signal
x=1:length(y);
fs=2048e3; % Sampling Frequency
n=length(y); % Length of my signal
t = (0:(n-1))*(1/fs); % Time appointed for every sample, first sample at time t=0 , next tn=t0+n*(1/fs)
x=t;
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0);
% Returns Approximate Zero-Crossing Indices Of Argument Vector
dy = zci(y);
% Indices of Approximate Zero-Crossings
for k1 = 1:size(dy,1)-1
b = [[1;1] [x(dy(k1)); x(dy(k1)+1)]]\[y(dy(k1)); y(dy(k1)+1)];
% Linear Fit Near Zero-Crossings
x0(k1) = -b(1)/b(2);
% Interpolate ‘Exact’ Zero Crossing
mb(:,k1) = b;
% Store Parameter Estimates (Optional)
end
figure(1)
plot(x, y, '-r')
hold on
plot(x(dy), y(dy), 'bp')
hold off
grid
the output I get is this photo below but the zero crossing point isn't correct - the points of zero crossing isn't accurate, isn't the exact zero crossing points !! .. the points of zero crossing should their positions be on the line of zero - implicitly the zero crossing points should be the intersections points of x axis-:
Could anyone please help me how can I implement in matlab zero crossing points of exact zero crossing points?! thanks alot
  댓글 수: 1
Jimmy cho
Jimmy cho 2020년 10월 19일
I've already seen posts and thread of @Star Strider answers but Im still not solving my problem.
Appreciated for any help guys!

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2020년 10월 19일
You are plotting the values of the data at the indices that ‘zci’ returns, not the interpolated aero-crossings.
It would be best to plot the linearly-interpolated x-coordinate values ‘x0’:
plot(x0, zeros(size(x0)), 'o')
Use whatever marker you want.
That should work.
  댓글 수: 4
Star Strider
Star Strider 2020년 10월 19일
My knowledge of digital communications engineering is at this point infinitesimal. (My last exposure to it was decades ago, and not much then.) I would like to help, however that is far outside my areas of expertise. (My apologies.)
It is highly likely that someone with necessary expertise will see it and respond, although that could take hours to a few days. In the interim, search the File Exchange to see what may be available.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by