MATLAB Answers


Simulink bit operations

Asked by Raldi
on 16 Dec 2011
Hi all, I wanted to ask if from a number of bits that are represented with 1 and 0 is possible to invert the ones to -1 each lets say two bits? Thanks in advance.


Not clear to me what do you mean by "from a number of bits" and "to invert the ones to -1 each lets say two bits". Are you saying that if you have an inputs of 10 bits, six 1s and four 0s, alternate randomly, you want to invert the first two 1s into -1?
basicaly i was trying to create an ami nrz line code, i think flip flops is the only way to do that. I havent finish it yet though.

Sign in to comment.

1 Answer

Answer by Paulo Silva
on 16 Dec 2011

[1 0]------>Gain(-1)----->[-1 0]
Use the Gain block and define that gain as -1


How many bits per time sample is your generator producing? If it is one bit per time sample then perhaps use a step function that flips between -1 and 1 every two steps.
Ah, instead of a step function, you could perhaps use a Repeating Sequence block, as mentioned at
I was thinking more of using a flip flop as it has memmory, The general idea was to create a simple ami-nrz line code.

Sign in to comment.