필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
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!

채택된 답변

Wan Ji
Wan Ji 2021년 8월 18일
편집: Wan Ji 2021년 8월 18일
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
Krasimir Terziev
Krasimir Terziev 2021년 8월 18일
편집: Krasimir Terziev 2021년 8월 19일
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 2021년 8월 19일
It‘s my pleasure to help you. ^o^

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by