count the duration for which variable value is zero in simulink

3 vues (au cours des 30 derniers jours)
Manish
Manish le 23 Juil 2012
t=(1:1:24); I=[0 0 0 1 1 1 2 2 2 5 5 5 10 10 10 15 15 15 5 5 5 0 0 0];
If these are the inputs in Simulink using a lookup
How can I determine the period for which the variabe (I) has the value of 0
Any help on this will be appreciated
Thanks.
regards Manish
  2 commentaires
K E
K E le 24 Juil 2012
Do you need the duration that I=0 during the simulation, or after it has finished?
Manish
Manish le 24 Juil 2012
During the Simulation.

Connectez-vous pour commenter.

Réponse acceptée

C.J. Harris
C.J. Harris le 23 Juil 2012
I'd take the input and convert it into a logical signal (1's and 0's), inverse this signal using a NOT block. Convert this back to a number (again, 1's and 0's) and feed it through an integrator block. The integrator output will then increase by a factor of 1 each second the input is non-zero. This output will then equal the amount of time your signal was zero.
  4 commentaires
Manish
Manish le 24 Juil 2012
Thanks C.J.Harris it was really helpful. Just one last question will this logic be applicable if I want to check it for a variable value like 1 or 2 instead of zero?
C.J. Harris
C.J. Harris le 25 Juil 2012
Yes, you would need a slight modification though. Instead of converting the signal straight to a logical you would have to compare it against a constant.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur General Applications dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by