Effacer les filtres
Effacer les filtres

How to calculate the whole time that my signal values is more than zero?

3 vues (au cours des 30 derniers jours)
Krasimir Terziev
Krasimir Terziev le 18 Août 2021
Commenté : Wan Ji le 19 Août 2021
Hello,
I'm stuck in the middle of my model and im wondering how i can do one simple calculation.
On the picture below u can see my signal.
I try to find out how much time the signal is greather than zero? Im tring to do it with simulink blocks.
Can anyone help me with this? I will be very thankful !
Тhank you in advance!

Réponse acceptée

Wan Ji
Wan Ji le 18 Août 2021
Modifié(e) : Wan Ji le 18 Août 2021
If your signal array is A, and with a time array t the same size as A.
The total time the signal is greater than zero will be
A = A(:); t = t(:);
q = A>0;
dt =[0;diff(t)];
t_positive = sum(dt(q)) % total time the signal is greater than zero
  3 commentaires
Krasimir Terziev
Krasimir Terziev le 18 Août 2021
Modifié(e) : Krasimir Terziev le 19 Août 2021
Hello,
Thanks for the fast answer. Тhis is not exactly what I was looking for but the code working fine when i take the scope data into the workspace. (btw the A array and t array are aways the same - they are the x and y in scope block).
I find what im missing.
1st my model is a phasor with max step size to 5 and simulation time to 24*60*60*7 (7 days).
in that case when i put my signal into enable subsystem with specific structure inside(shown in the picture below) its going well BUT instead of const = 1, it have to be the same as the max step size. So the const = 5 now and it calc. as the same your code above! Now nometter the what max step size i use, its the same answer!!!
Thank you very much for helping me !
Wan Ji
Wan Ji le 19 Août 2021
It‘s my pleasure to help you. ^o^

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by