How to calculate the whole time that my signal values is more than zero?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Krasimir Terziev
am 18 Aug. 2021
Kommentiert: Wan Ji
am 19 Aug. 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!

0 Kommentare
Akzeptierte Antwort
Wan Ji
am 18 Aug. 2021
Bearbeitet: Wan Ji
am 18 Aug. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!