How can I count the number of times an input reaches a certain value?

3 views (last 30 days)
Hello,
I am using Simulink where I have a model of a heat pump, where I simulate frost accumulation. What I am trying to do is count the total number of times (during the simulation) the Frost layer thickness has reached 8.25 mm for example.
I have tried various methods, such as implementing switches, sum blocks, delay blocks, nothing has worked so far. At least not properly.
I cannot provide much details as the project is confidential. But part of the task is to count how many times the frost sheet on the outdoor unit has reached a certain value.
P.S. I do not have much experience with MatLab commands and scripts. I would really appreciate solutions solely involving Simulink.

Answers (1)

Jonas
Jonas on 19 Feb 2021
Take the signal for the frost layer thickness, use a Relational Operator to compare if the signal is larger than a constant of 8.25 (second input). The output will be a boolean telling true or false. Connect this boolean signal to a Triggered Subsystem. Inside this triggered subsystem, you could for example use a Data Store Read and Data Store Write block, where it reads from the read block, adds 1 to it, and writes it to the write block. The Data Store Memory block should be located outside the triggered subsystem. There are also possibilities by using a Unit Delay block and adding it with one.

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!