📄 resolvethelastbit.m
字号:
function[bits_alloc,energy_alloc] = ResolvetheLastBit(bits_alloc,energy_alloc,index,energytable,num_subc);
max_val = 0;
for i =1:num_subc
if(i~=index & bits_alloc(i)==1)
if bits_alloc(i)~=0
temp = energytable(i,bits_alloc(i));
end
if(temp>max_val)
max_val = temp;
max_ind = i;
end
end
end
min_val = Inf;
for i = 1:num_subc
if(i~=index & bits_alloc(i)==1)
if bits_alloc(i)~=0
temp = energytable(i,bits_alloc(i)+1);
end
if(temp<min_val)
min_val = temp;
min_ind = i;
end
end
end
if(min_val<max_val)
bits_alloc(min_ind) = bits_alloc(min_ind)+1;
bits_alloc(index) = bits_alloc(index)-1;
energy_alloc(index) = energy_alloc(index)-min_val;
else
bits_alloc(max_ind) = bits_alloc(max_ind)-1;
bits_alloc(index) = bits_alloc(index)+1;
energy_alloc(index) = energy_alloc(index)+max_val;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -