Problem in matlab implementation zero crossings detector

2 views (last 30 days)
Hi guys!
I have Ac singal it's implicitly vector sized as 1X32000 samples (vector that its values are samples). and if I do plot in matlab then I get signal like sinusoidal signal
Im trying to do zero crossing in matlab in order to detect where I have edges in my input signal (ac sampled signal-vector of samples) ! , I must do in matlab code the zero crossings by interpolation methods -if you see the photo that I attached it's the red dots .. - and I want afterwards to subtract between each adjacent two red dots of zero crossings dots and find the time between those every two red dots (in my photo down for instance the subtraction between two red dots-two point of zero crossings- are 5sec .. at the end of my signal the difference between the two last point of zero crossings are 10sec) .. so I need to calculate the difference between every two adjacent zero crossings points, afterwards to find the value (in other words it's y value-amplitude value of time(x axis)) of the middle of every two adjacent zero crossings point - see please the photo down I drew blue line at every middle of two zero crossings- , then I take the amplitude of every middle of every two adjacent zero crossings point and make those condition:
if (amplitude of the middle of two adjacent crossing point >0 ) => 1 , I save that 1 in another array correspondly .
if (amplitude of the middle of two adjacent crossing point <0 ) => 0 , I save that 0 in another array correspondly .
in my example that Im attaching in my photo down I would get at the end this output : 0101 .
more clarification about my example, here the output is 0101 and here's the explanation why it's 0101 :
first the median of two first adjacent zero crossing is negtive (where there's blue line in first envelop ..amplitude is negative) so in another array or string I save 0.
second median of two second adjacent zero crossing is positive (where there's blue line in second envelop ..amplitude is positive ) so in another array or string I save 1.
etc ....
Could anyone please help me how can I do that in matlab? I really stuck in this about two weeks, I tried by myself many attempts and I didn't succeed to get the required outputs..thanks for any help!!!!!
just noting that the output could be array or concanating string that I save to it the value 0/1 that's result of conditions ..
Appreciated for any help /assistance!
Attaching down my signal (sampled signal= vector of samples).
Mohamed Jamal
Mohamed Jamal on 14 Jul 2020
Anyway I would thank you if you could help me in this, appreciated.

Sign in to comment.

Answers (0)


Community Treasure Hunt

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

Start Hunting!