Search code examples
simulink

Detect in simulink if the current and past 4 values are same or not


I am interested in designing a simulink block which detects if the past 4 and the current input values are same or not. How to do it using the delay blocks and relational operators since the relational operators take only two inputs at a time?


Solution

  • I think if you 4 Unit Delay blocks in succession, you will get the previous 4 values by looking at the output of each block. You didn't say whether you were using a fixed-step or variable-step solver. Normally, you should be using a fixed-step solver for this type of operation.

    With regards to the equality test, I would recommend comparing the absolute value of the difference between the 2 numbers to a small threshold rather than doing a pure equality test, especially if your signals are of the double data type. The blocks you need for that are: