www.pudn.com > mimoprecoding.rar > codebook_select.m, change:2006-07-11,size:1771b


function [index feedback_bits] = codebook_select(cir,sim_options) 
global sim_consts; 
[n_tx_antennas, n_rx_antennas] = get_n_antennas(sim_options); 
cir = transpose(cir); 
[temp_r,temp_c] = size(cir); 
cir_f = zeros(64,temp_c); 
for i = 1 : temp_c 
    cir_f(:,i) = fft(cir(:,i),64); 
end 
cir_tx = zeros(2*64,temp_c/2); 
pattern = [1:2:2*64;2:2:2*64]; 
for i = 1 : temp_c/2 
    cir_tx(pattern(1,:), i) = cir_f(:,i); 
    cir_tx(pattern(2,:), i) = cir_f(:,i + temp_c/2); 
end 
for i = 1 : 64 
    for j = 1 : n_rx_antennas 
        cir_tx_subc(j,:,i) = cir_tx(j+(i-1)*n_rx_antennas,:); 
    end 
end 
ww=[]; 
for k =1 :64 
    [u s v] = svd(cir_tx_subc(:,:,k)); 
    ww = [ww s(1,1)]; 
end 
w = sim_consts.beamformingvec; 
% w = w ./ repmat(s,4,1); 
[temp_r,temp_c] = size(w); 
index = []; 
for k = 1 : 64 
    index_temp = 1; 
    max_snr = abs((transpose(w(:,1)) * transpose(cir_tx_subc(:,:,k)))*(transpose(w(:,1)) * transpose(cir_tx_subc(:,:,k)))');%sum(abs((transpose(w(:,1)) * transpose(cir_tx_subc(:,:,k)))).^2);%norm(transpose(w(:,1)) * transpose(cir_tx_subc(:,:,k)))^2; 
    for i = 2 : temp_c 
        temp = abs((transpose(w(:,i)) * transpose(cir_tx_subc(:,:,k)))*(transpose(w(:,i)) * transpose(cir_tx_subc(:,:,k)))');%sum(abs((transpose(w(:,i)) * transpose(cir_tx_subc(:,:,k)))).^2);%norm(transpose(w(:,i)) * transpose(cir_tx_subc(:,:,k)))^2; 
        if temp >= max_snr 
            index_temp = i; 
            max_snr = temp; 
        end 
    end 
    index = [index index_temp]; 
end 
temp = index(1); 
feedback_bits = 1; 
for k = 1 : 64 
    if index(k) ~= temp 
        feedback_bits = feedback_bits + 1; 
        temp = index(k); 
    end 
end 
%  
feedback_bits = feedback_bits * (6 + 6); 
    

2018无需申请注册送58体验金