MATLAB Answers

Zero crossings and separation of data

2 views (last 30 days)
Adam Bryant
Adam Bryant on 21 Oct 2020
Answered: Star Strider on 21 Oct 2020
I am currently trying to write a code that will divide each iteration of a set data that only comprises of voltage values up into separate figures/entities after the last zero crossing of each iteration as well as record the first zero crossing of each. Within the provided figure (picture), one iteration is highlighted in red. Currently the data is only 10 iterations of an experiment, but I eventually want to record over 100 iterations and process the data through a MATLAB code. Any and all help is appreciated. Thank you.

  1 Comment

Rik on 21 Oct 2020
What did you try already? Have a read here and here. It will greatly improve your chances of getting an answer.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 21 Oct 2020
Use the envelope function to define the ‘outline’ of the upper portion of the signal (and the lower portion if you want that), then use:
zci = @(v) find(diff(sign(v)));
with ‘v’ being the envelope vector to define the indices of the zero-crossings:
env = envelope(yourSignal);
zxidx = zci(env);
then take it from there.


Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!