How to create a buffer FIFO, filter and then save in an array values that are between an specific range of values?

I have a sine wave as input signal at a sampling rate of 0.02. I want to process the first 1000 sampling points = 20 sec in a FIFO buffer
Signal ---> buffer size (1000) ---> full --> save in an array only values that are negative. --> next 20 seconds.
This is the simulink implementation that I have so far. My idea is to have two signals the real one an the delayed one. Save in a buffer the data from the delayed signal. Lets say that the delayed signal has a delay of 20 seconds, from this one I buffer the first 20 seconds and apply my filter of negative values and save them in an array. That means that when I buffer the next 20 are ready to be buffered, processed and filter.
Hope we can discuss some good ideas!

5 Comments

Thanks! I also started to use the buffer box. Why the unbuffered box is also added?
unbuffered box :
It is simply to facilitate understanding.

Sign in to comment.

 Accepted Answer

I attached modified model you made.
unbuffer is just for the description of the block. It is arranged to explain the difference from Buffer. There is no more meaning.

7 Comments

How would you suggest to filter every set of data (1000 sampling points)
I have two signals, Signal1 and Signal2
My first filter is to delete the first 50 and last 50 sampling points of each buffered set. At the end I will have only 900 sampling points. After that I need to save in array only when Signal2 values lower than 0.
Small concept example:
Buffer size = 3
Signal1: [ 1.2 1.5 1.6 1.7 1.4 2 1.8 1.7 1.4 1.3 2 2.1]
Signal2: [ 0.8 0.9 1 0.8 -0.2 0.7 0.6 0.4 0 -0.3 -0.5 - 0.7]
Ts : [ 0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.2 0.22 0.24] (timestamp)
S1 S2 Ts
Matrix concat: 1.4 -0.2 0.1
1.3 -0.3 0.2
2 -0.5 0.22
2.1 -0.7 0.24
I need to have as a result a Matrix whenever the system detects that signal2 has negative values and save the corresponding values of signal1 at that time.
I also need to save in the matrix the timestamp, to be aware when the values lower than zero ocurred.
Do you any ideas of how to do that?
I cant open them, because they are version R2019b and I have R2018b.
What is the difference between the two attached files? I also would like to ask. How is this change of color made? Looks nice
How can I delete the data from previous steps. I dont want accumulate all values in the matrix. I just want to have a fixed number of 1000 values inside this matrix.

Sign in to comment.

More Answers (0)

Products

Release

R2018b

Asked:

on 15 Feb 2020

Commented:

on 18 Feb 2020

Community Treasure Hunt

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

Start Hunting!