Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Wan Ji
Wan Ji el 18 de Ag. de 2021
Editada: Wan Ji el 18 de Ag. de 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 comentarios
Krasimir Terziev
Krasimir Terziev el 18 de Ag. de 2021
Editada: Krasimir Terziev el 19 de Ag. de 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 !

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre General Applications en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by