representing 8 bits per element

In the previous post
walters comment
Remember, comp is representing binary, and so is 1 bit per element, whereas your original data is at least 8 bits per element.
now how to represent binary element as 8 bits per element
binary values are stored in comp

댓글 수: 1

Image Analyst
Image Analyst 2012년 12월 27일
Why wasn't this posted in that previous post then? Why did you start a whole new discussion?

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

 채택된 답변

Walter Roberson
Walter Roberson 2012년 12월 27일

0 개 추천

Provided your vector comp is an exact multiple of 8 long:
x = comp; %just to make the writing shorter
uint8( x(1:8:end) * 128 + x(2:8:end) * 64 + x(3:8:end) * 32 + x(4:8:end) * 16 + x(5:8:end) * 8 + x(6:8:end) * 4 + x(7:8:end) * 2 + x(8:8:end) )

댓글 수: 6

walter i get error
??? Error using ==> plus Matrix dimensions must agree.
size(x)
ans =
167770 1
till x(2:8:end) * 64;
the size is
20972 1
after that the size is
20971 1
Walter Roberson
Walter Roberson 2012년 12월 27일
As I said, "Provided your vector comp is an exact multiple of 8 long"
If it isn't, then pad it with zeros.
FIR
FIR 2012년 12월 27일
walter every time the size is varying
while length(x) ~= 8 * floor(length(x)/8)
x(end+1) = 0;
end
FIR
FIR 2012년 12월 27일
thanks a lot

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

FIR
2012년 12월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by