How to map decimal vector to look up table?

조회 수: 1 (최근 30일)
Jyothi Alugolu
Jyothi Alugolu 2017년 2월 9일
편집: Jan 2017년 2월 9일
Hello,
i have decimal vector of size <1x203 double> with values 244,255,245,0,239,217...Now i have to create a lookup table of size <256x9>,where 256 row size is to map every decimal element to corresponding index value of look up table.. if suppose if the value in decimal vector is 244, then there should be mapping between decimal vector value 244 to index value 244 of lookup table... and if any decimal value repeats, then there should be mapping to the same index value of lookup table . and column size 9 is for, 1st bit must be the index value and the remaining 8 bits is for random equal number of 0's and 1's... can anyone help me how to do this?
  댓글 수: 3
Jyothi Alugolu
Jyothi Alugolu 2017년 2월 9일
And one more thing to do,if the decimal value is 244,then the corresponding lookup table value 244 which consists of 8 random 0's and 1's,have to get 3 to 6 bit positions from 8 bits and store in separate array..so the final output must be an array with size 1*812(812 because the decimal vector size is 203 and the values in 203 cells are mapped to corresponding lookup table and 4 bits are being taken from the corresponding lookup table..so 203*4=812).
Guillaume
Guillaume 2017년 2월 9일
Please give a short, concrete, example with numbers of inputs and desired output. Your explanation is far from clear.

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

답변 (2개)

Jan
Jan 2017년 2월 9일
편집: Jan 2017년 2월 9일
Data = randi([0, 255], 1, 203); % Test data
LUT = [(0:255).', randi([0,1], 256, 8)];
Now the lookup table is used by simple indexing:
Result = LUT(Data, 4:7); % Get bits 3 to 6 from the binary data
Result = Result(:); % To get a 812x1 vector

Stephen23
Stephen23 2017년 2월 9일
In MATLAB the most efficient way to do this is to simply use indexing:
>> V = randi([0,255],1,203);
>> idx = V==244; % logical indices
>> find(idx) % subscript indices
ans =
34 55 87

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by