Simulink bit operations
이전 댓글 표시
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.
댓글 수: 2
Fangjun Jiang
2011년 12월 17일
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?
Raldi
2012년 1월 13일
답변 (1개)
Paulo Silva
2011년 12월 16일
[1 0]------>Gain(-1)----->[-1 0]
Use the Gain block and define that gain as -1
댓글 수: 7
Raldi
2011년 12월 16일
Paulo Silva
2011년 12월 16일
Yes you are right, it's something easy to do in MATLAB but not in Simulink, maybe someone can help you with a better solution
Paulo Silva
2011년 12월 16일
For that example you can try the Product block and use element wise operations
[1 1 0 1]----->Product>----[1 -1 0 1]
[1 -1 1 1]---->_______
Raldi
2011년 12월 16일
Walter Roberson
2011년 12월 16일
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.
Walter Roberson
2011년 12월 16일
Ah, instead of a step function, you could perhaps use a Repeating Sequence block, as mentioned at http://www.mathworks.com/matlabcentral/answers/15874-hi-all-i-am-having-a-difficulty-in-switching-a-signal-i-need-a-switch-in-simulink-that-must-be-on
Raldi
2012년 1월 13일
카테고리
도움말 센터 및 File Exchange에서 Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!