⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug.m

📁 这个第四代移动通信中
💻 M
字号:
function debug();
load qam16_symble;          %   symbols after qam16_mapping 
load V_blast_symble_block;  %   symbols after v-blast module
load IFFT_symbols;          %   symbols after ifft
load Space_freq_symbols;    %   symbols paper
load channel_fir;           %   fir channel use in the simulation

load A_tag;                 %   to get Label matrics

%----------------------debug start----------------
a = squeeze(antena_index_symbols(1,:,:));
a1 = a(:,1);
a_dft = n_point_idft_array(8)*a(:,1)/8; %   to ger the ifft of function calling ifft symbols

b = squeeze(IFFT_symbols(1,:,:));       %   to get the ifft symbols of the ist colunm
b1 = b(:,1);

a_dft-b1
%----------------------debug end --------------------


m_transmitter = 4;      %
n_receiver = 4;         %
fir_len = 4;
subcarrier_num = 8
P = [diag(ones(1,fir_len + 1)) zeros(fir_len + 1,subcarrier_num - fir_len - 1)];
DFT8_array = n_point_dft_array(subcarrier_num);


channel_fir(m_transmitter, n_receiver, index)

a = [1:8];
aa = reshape(1:18,2,9)
b = zeros(3,9)

size_in_bit = size(IFFT_symbols);
size_m_trans = size_in_bit(1,1);    %   this para is the number of transmitter
size_n_point = size_in_bit(1,2);    %   this para is G subcarriers
size_layer = size_in_bit(1,3);      %   layer number

%--------------------------------------------------------------------------
%   function channel = firChannel(m_transmitter, n_receiver, n_fir);
%   to creat the fir channel 
%   other way, it needs to offer a fir channel save as chan;

fir_len = 4;
m_trans = 4;
n_rcv = 4;

channel_fir = firChannel(4,4,4);
cur_h_nm = squeeze(channel_fir(1,1,:))';
save channel_fir channel_fir;


P = [diag(ones(1,fir_len + 1)) zeros(fir_len + 1,subcarrier_num - fir_len - 1)];
DFT8_array = n_point_dft_array(subcarrier_num);
F_fro = P * DFT8_array  %(L+1)*G

for index_m = 1:m_transmitter
    for index_sub = 1:n_rcv
        cur_h_nm = squeeze(channel_fir(1,1,:))';
            
        
        
channel_fir = firChannel(2,4,4);
cur_h_nm = squeeze(channel_fir(1,1,:))';
save channel_fir channel_fir;




%---------------------------------------------------------------
%                20070101 simulation para records
%---------------------------------------------------------------
m_transmitter = 4;      %
n_receiver = 8;         %
fir_len = 1;
QAM_bit = 2;
N_point_FFT = 4;
symbol_block_K = 25;
SNR_dB = 30;

chan_h = firChannel(m_transmitter, n_receiver, fir_len);
channel_H = gen_freq_H(chan_h, N_point_FFT);

R_HH = channel_H * channel_H';
%V_blast_symble_block = transmitter(m_transmitter, QAM_bit, N_point_FFT, symbol_block_K);
S = transmitter(m_transmitter, QAM_bit, N_point_FFT, symbol_block_K);

%----------------------------step 1--------------start--------------
Y_H = S * channel_H;      
%signal_level_Y = mean(mean(abs(S).^2));
%signal_level_Y_dB = 10*log10(signal_level_Y);
%Y = awgn(Y_H,(SNR_dB + 10*log10(QAM_bit)),signal_level_Y_dB); 
Y = awgn(Y_H,(SNR_dB + 10*log10(QAM_bit)),'measured');          %   jie shou xin hao Y

A = diag(gen_tag(m_transmitter, N_point_FFT));
Z_H = S * A * channel_H;  
%signal_level_Z = mean(mean(abs(S).^2));
%signal_level_Z_dB = 10*log10(signal_level_Z);
%Z = awgn(Z_H,(SNR_dB + 10*log10(QAM_bit)),signal_level_Z_dB); 
Z = awgn(Z_H,(SNR_dB + 10*log10(QAM_bit)),'measured');          %   jie shou xin hao Z

R_YY = Y * Y';                      % jie shou xin hao Y zi xiang guan
R_YY0 = S * R_HH * S'; 

R_ZY = Z * Y';                      % jie shou xin hao Y & Z hu xiang guan
R_ZY2 = S*A*R_HH*S';
%----------------------------step 1----------------end------------

%R_ZY = S * A * R_HH * S';
%Rank_HH = rank(R_HH);
%Rank_YY = rank(R_YY);
%Rank_YY2 = rank(R_YY');

%----------------------------step 2-------------------------------
%[VV, DD] = eig(R_YY); % R_YY * V = V * D
[S_svd, V, D] = svd(R_YY);
mu = diag(V)';
%mu = real(diag(D)');
%size(mu);

%R_YY2 = 0;
%for index = 1 : symbol_block_K
 %   temp = mu(index) * V(:,index) * V(:,index)';
  %  R_YY2 = temp + R_YY2;
  %end;

%
%cut
%

%   step 3
sigma2 = sum(mu(m_transmitter * N_point_FFT + 1 : symbol_block_K))/...
    (symbol_block_K - m_transmitter * N_point_FFT);

%   step 4
R_YY0_P = 0;
for index = 1 : (m_transmitter * N_point_FFT)
    temp = (mu(index) - sigma2)^(-1) * S_svd(:,index) * S_svd(:,index)';
    R_YY0_P = R_YY0_P + temp;
end;

R = R_ZY * R_YY0_P;
R2 = R_ZY2 * R_YY0_P;
[S_R, V_R, D_R] = svd(R);
mu_R = diag(V_R);

reslut = R * S_R - S_R * A

reslut = R2 * S - S * A
%cut

%   this part is to get the eig value of matrix R_YY---the corelation of Y
mu_int  = real(mu)';
index = 1;
while index <= length(mu_int)
    if mu_int(index) < 10^(-8)
        mu_int(index) = 0;
    end;
    index = index + 1;
end;

[VV, DD] = eig(R_YY0)
mu = diag(DD)';
R_YY0_P1 = 0;
R_YY0_P2 = 0;
for index = 1 : symbol_block_K
    temp1 = VV(:,index) * VV(:,index)';
    temp2 = VV(index,:) * VV(index,:)'
    R_YY0_P1 = R_YY0_P1 + temp1;
    R_YY0_P2 = R_YY0_P2 + temp2;
end;
R_YY0_P1
R_YY0_P2


%-------------------------------------20070105-----------------------------
%-
clear
clc
for SNR = 1:2:31
    [tag_opt,tag_decode,Tag_diff] = run_sim(SNR);
    tag_opt((SNR+1)/2,:) = tag_opt;
    decode_tag((SNR+1)/2,:) = tag_decode;
    diff((SNR+1)/2,:) = Tag_diff;
    pow_diff((SNR+1)/2) = mean(Tag_diff.^2);
end;

angle_A(1) = 0.6247
V_R(:,1)
angle_A_opt(4) = 0.625
S(:,4) = 


%-------------------20070108-----------
%-----DEBUG

DDDD1 = diag([1,2,3]);
DDDD2 = diag([3.0001,2,00001,1.00001]);
VVVV1 = [1,2,3;1,2,3;1,2,3];
VVVV2 = [3.0001,2,00001,1.00001;3.0001,2,00001,1.00001;3.0001,2,00001,1.00001];

[DDDD2_sort, VVVV2_sort] = sort_D_V_opt(DDDD1, DDDD2, VVVV2)

%%%%%%%%%%%%%%%%%%%%%%%      DEBUG 20070109
%%%%%%%%%%%%%%%%%%%%%%%      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%---------------------------------decoding--------------------------------
for index = 1:symbol_block_K
    if abs(D_R(index,index)) > 10^(-10)
        angle_A(1,index) = angle(D_R(index,index))/pi;
    else
        angle_A(1,index) = 0;
    end;
end;

for index = 1:symbol_block_K
    if abs(D_R(index,index)) > 10^(-10)
        angle_A_opt(1,index) = angle(D_R_opt(index,index))/pi;
%         if angle_A_opt(1,index) < - (1+0.875)/2 
%             angle_A_opt(1,index) = angle_A_opt(1,index) + 2*pi;
%         end;
    else
        angle_A_opt(1,index) = 0;
    end;
end;

angle_A_sort = sort(angle_A(1:16));
angle_A_opt_sort = sort(angle_A_opt(1:16));

tag_opt = angle_A_opt_sort;
tag_decode = angle_A_sort;
Tag_diff = angle_A_sort - angle_A_opt_sort;


%Debug
% diff_out_tag = angle_A - angle_A_opt
% for index = 1: symbol_block_K
%     if abs(angle_A(index)) > 10^(-6)
%         angle_receive(index) = angle_A(index) + 2/(m_transmitter * N_point_FFT);
%     end;
%     %if abs(angle_A_opt(index)) > 10^(-6)
%         angle_receive_opt(index) = angle_A_opt(index) + 2/(m_transmitter * N_point_FFT);
%         %end;
% end;

for index = 1: m_transmitter * N_point_FFT
    angle_receive_opt(index) = angle_A_opt(index) + 2/(m_transmitter * N_point_FFT);
end;


real_V_R = real(V_R);
code_V_R_plus = (real_V_R > 0.0001);
code_V_R_minus = (real_V_R < -0.0001);
real_V_R = code_V_R_plus - code_V_R_minus;

imag_V_R = imag(V_R);
imag_V_R_plus = (imag_V_R > 0.0001);
imag_V_R_minus = (imag_V_R < -0.0001);
imag_V_R = imag_V_R_plus - imag_V_R_minus;

symbols = real_V_R + j*imag_V_R

islogical(L)
imag_V_R = imag(V_R);
if real_V_R >0.00001
end;
V_R

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -