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

1 visualización (últimos 30 días)
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.

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 22 de Nov. de 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.

Categorías

Más información sobre Schedule Model Components en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by