resolvethelastbit.m
来自「matlab编写的MIMO-OFDM仿真程序」· M 代码 · 共 39 行
M
39 行
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 + =
减小字号Ctrl + -
显示快捷键?