check if a condition is true for a certain time (Simulink)

I have a simple problem but i can't find a solution.
I have the following model:
and I would like to get 1 as output of this model when the condition is respect for 0.8 consecutive seconds.
How can i do it?

Answers (1)

Connect this condition to an integrator. If the condition is true, the integration will increase. Compare it to 0.8, you will get the result. Specify the integrator to be reset by external source. Use the fall edge or low level of your condition to reset it.

4 Comments

Thanks, it worked!
I have another question, if I can.
I have a certain signal that change greatly (both increasing and decreasing) with time and i would like to create a model that receives this signal as input and as output I get the same signal but evaluated every 0.2 seconds.
What I mean is that the model check the value of the signal at 0, keep this value for 0.2 seconds, than check again the value of the signal, keep this value to 0.4 and so on...
zero-order holder, set the sample time as 0.2s
Fengjun Jiang.. You are such a genius
Thank you 10 times per second for 50 years.

Sign in to comment.

Categories

Find more on Simulink in Help Center and File Exchange

Products

Asked:

on 10 Mar 2020

Community Treasure Hunt

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

Start Hunting!