フィルターのクリア

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

3 ビュー (過去 30 日間)
Krasimir Terziev
Krasimir Terziev 2021 年 8 月 18 日
コメント済み: Wan Ji 2021 年 8 月 19 日
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 Center および File ExchangeGeneral Applications についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by