필터 지우기
필터 지우기

Replacing 5 bits in a binary value

조회 수: 3 (최근 30일)
kash
kash 2012년 11월 22일
편집: Abdul Gaffar 2019년 12월 5일
i have two vales such as
A=1078;
B=25;
now i want to embed this B value in A ,embedding layer is 8,
Binary value of A is 10000110110
Binary value of B is 11001
after embedding in 8th position fron LSB I WILL GET 10011001110
please help

채택된 답변

Pedro Villena
Pedro Villena 2012년 11월 22일
편집: Pedro Villena 2012년 11월 22일
C = dec2bin(A);
D = dec2bin(B);
n = 4; %%start bit position from MSB (1st bit position is 1)
C(:,n:n+size(D,2)-1)=D %%replace of some bits of C from D
  댓글 수: 2
kash
kash 2012년 11월 22일
Thanks Pedro if there are more values in A and B
say A=[1056;1078]
B=[31;25];
i tried using
for i=1:2
C(n:n+numel(D)-1)=D;
end
but not getting the answer
Abdul Gaffar
Abdul Gaffar 2019년 12월 5일
편집: Abdul Gaffar 2019년 12월 5일
Though its been very long time, I have seen today:
A = [1056;1078];
B = [31;25];
C = dec2bin(A)
D = dec2bin(B)
n = 7; %%start bit position from MSB (1st bit position is 1)
C(:,n:n+size(D,2)-1) = D
Output: C

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by