How to count the amount of times a specific number appears on an output wave?

1 vue (au cours des 30 derniers jours)
Anton Garcia
Anton Garcia le 22 Nov 2020
I've created a model that can count how many times the sawtooth waveform reaches the value of 2. However, this is a value in the middle and I've only seen so far how to count the number of rising/falling edges in Simulink so I have no idea how to make it work. Here is my code and model so far. The ideal output should have been a step wave form that starts at 0 then increases to 1 then eventually further increases to 6 at the end since the number 2 appears 6 times in the waveform.

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 22 Nov 2020
Compare your signal with the value of 2, if greater than 2, output true, otherwise false. The output is a square wave. Use this square wave to trigger a triggered subsystem, using both the rising and alling edge. The subsystem will be triggered 6 times. You can have a counter inside to get the desired output.

Catégories

En savoir plus sur Schedule Model Components dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by