How to allow only sequences that have had the same value for 5 seconds (in Simulink)?

3 ビュー (過去 30 日間)
black_cat
black_cat 2021 年 9 月 21 日
編集済み: black_cat 2021 年 9 月 22 日
I have an input like this:
[2, 2, 2, 2, 3, 2, 2, 2, 3, 4, 4, 4, 4]
I want to suppress oscillation and only allow sequences that have had the same value for x seconds (e.g. 5). So that it outputs the above sequence like this:
[2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]
Is there a way to do this using blocks in Simulink?
  5 件のコメント
Jonas
Jonas 2021 年 9 月 21 日
I still don't know why it would output [2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]. There has not been five consecutive '3' in the input data. If you want the data to only jump when the value is 5 times the same consecutively, the output will be:
  • Input: [2, 2, 2, 2, 3, 2, 2, 2, 3, 4, 4, 4, 4]
  • Output: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
black_cat
black_cat 2021 年 9 月 21 日
Yeah, because you assume that the consecutive number is coming from the input, but it is about the output.

サインインしてコメントする。

回答 (1 件)

Jonas
Jonas 2021 年 9 月 21 日
Using only blocks, I think this should do the trick:
  1 件のコメント
black_cat
black_cat 2021 年 9 月 22 日
編集済み: black_cat 2021 年 9 月 22 日
Thank you very much. This is the solution that solved my problem:
However, this only helps me with the values that occurred in the last 5 seconds. Does anyone know how can I apply this to the last 50 seconds without adding 40 more delay blocks?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSignal Attributes and Indexing についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by