How do I count the number of times zero is being crossed by a signal?
27 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Rajesh Siraskar
le 8 Jan 2020
Modifié(e) : hossein
le 2 Fév 2022
Hi,
I am trying to build a control system and I want to count the oscillations in a time-span of say 100 seconds.
Can I count the number of times a signal crosses zero (probably using MATLAB's zer-crossing detection algo.) to count the oscillations?
I want it to happen within Simulink - is there any other better way? I just want a count say 10, that tells me there were 10 oscillations.
0 commentaires
Réponse acceptée
Fangjun Jiang
le 8 Jan 2020
If you have the DSP toolbox, there is a Zero-Crossing counter block. If not, you can compare the signal with zero, which creates a square wave signal. Use the rising and falling edge to trig an triggered subsystem, inside which adding a Counter block.
8 commentaires
Fangjun Jiang
le 9 Jan 2020
I believe continuous solver should also work. You just need to add DataTypeConversion blocks to deal with those data type mismatches.
Plus de réponses (1)
hossein
le 2 Fév 2022
Modifié(e) : hossein
le 2 Fév 2022
You can count the number of times the product of the signal and the shifted signal becomse negative. The below formula gives the number of crossings I guess. I am not sure if this is bug free.
"Sig" is your signal data vector here.
sum(sign((Sig.*[Sig(2:end),Sig(end)]))<0)
0 commentaires
Voir également
Catégories
En savoir plus sur Sources dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!