Search code examples
matlabsimulinkencoder

how to generate Alternate +1 & -1 sequence in MATLAB simulink


this is my first time using the MATLAB simulink i am trying to make a (Non-Return-to-Zero) level encoder , i cant fined a component for that, can any one help me please ?


Solution

  • If the time for the signal to spend at 1 and -1 is constant you could use a Pulse Block with amplitude 2 and shift it down by 1. This generates a square wave.

    Otherwise, you could use a Repeating Sequence Stair block to do this. This block takes a vector of values [1, 2, 7, -1, 3] and repeats a square signal by outputting and holding each of those values for the sample time.