hello, i want to perform left shift by 1 bit in this code for left_1 and right_1
% 1 2 3 4 5 6 7 8 9 10
key=[1 0 1 0 0 0 0 0 1 0]
IP=[3 5 2 7 4 10 1 9 8 6]
left=key(IP(1:5))
left_1=left
right=key(IP(6:10))
right_1=right

댓글 수: 3

James Tursa
James Tursa 2017년 2월 2일
What kind of shift? Circular shift? Fall-off-the-end shift? Shift bits to/from "left" variable and "right" variables?
ablaze
ablaze 2017년 2월 3일
circular shift
Walter Roberson
Walter Roberson 2017년 2월 3일
How many bits width?

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 2월 2일

0 개 추천

Multiply by 2.

댓글 수: 1

For 4 bits (as your values are small):
shifted = pre_shifted * 2;
mask = shifted >= 16;
shifted(mask) = shifted(mask) - 15;

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2017년 2월 2일

댓글:

2017년 2월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by