How to allow only sequences that have had the same value for 5 seconds (in Simulink)?
Show older comments
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 Comments
Jonas
on 21 Sep 2021
The fifth sample of the input shows a '3', and it is ignored. Why would the output suddenly become '3' starting from the 7th sample? There have not been '3' in the input for 5 consecutive samples. Reading from what you want to do, it should ignore the two '3' in the input because you want to discard it as noise.
black_cat
on 21 Sep 2021
Mathieu NOE
on 21 Sep 2021
hi
why not make a simple comparison between the actual data and what is stored in a buffer of length 5 (take the mean of the buffer)
if the data is matching the running buffer mean value (within a given tolerance) use that actual data, if not take the previous sample (suing "memory" or "delay" block)
my 2 cents
alternative : use a low pass filter (FIR or IIR)
Jonas
on 21 Sep 2021
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
on 21 Sep 2021
Answers (1)
Categories
Find more on Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
