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

📄 gmc_16qam_turbo.m

📁 B3g_phase2_C语言_Matlab程序及说明
💻 M
📖 第 1 页 / 共 2 页
字号:
clear
% Define parameters of MC filter banks
% Define parameters of MC filter banks
load ptfilter                                                             % load prototype filter coefficients which are saved in h
prototype_filter=h;
Carrier_number=16;                                                        % Number of subcarriers
SubCarrier_first=1;
SubCarrier_last=15;
Carrier_number_used=SubCarrier_last-SubCarrier_first+1;
Sampling_factor=18;                                                       % Factor of upsampling and downsampling
Oversampling_factor=2;    
Filter_length=217;                                                        % Length of filters in taps

% Define the slot structure
Spread_factor=8;                                                         % Spread factor
Subslot_number=8;                                                         % Number of subslots
Symbol_number_subslot=13;                                                  % Symbol number in a subslot
Symbol_number_slot=Subslot_number*Symbol_number_subslot;                  % Symbol number in a slot
Pilot_length=16;                                                          % Length of pilot signal in chips
Gaurd_length=8;                                                           % Length of gaurd time in chips
GaurdPilot_length=Gaurd_length+Pilot_length;                              % Total length of gaurd time and pilot signal in chips
SubslotData_length=Symbol_number_subslot*Spread_factor;                   % Length of data in a subslot in chips
Subslot_length=SubslotData_length+GaurdPilot_length;                      % Length of a subslot in chips
SlotData_length=Subslot_number*SubslotData_length;                        % Length of data in a slot in chips
Slot_length=Subslot_number*Subslot_length+GaurdPilot_length;              % Length of a slot in chips 

% Define spreading codes
Walsh=[1 1; 1 -1]/sqrt(2);                                                % Walsh matrix for speading codes 
for k=1:log2(Spread_factor)-1
    Walsh=[Walsh Walsh;Walsh -Walsh]/sqrt(2);
end
Code_channel=Spread_factor;                                               % Number of code channels
Walsh=Walsh(1:Code_channel,:)';                                           % The codes come from Walsh matrix 
Walsh=eye(Spread_factor);
% W_sequence=[1 j 1 -1 1 1 -1 -j 1 -j 1 1 1 -1 -1 j]/sqrt(16);
% for m=1:16
%     Walsh(m,:)=[W_sequence(16-m+2:16) W_sequence(1:16-m+1)];
% end


% Initialize the scrambler 
PN_RegStateI = [zeros(1,14) 1];  
PN_RegStateQ = [zeros(1,14) 1];  
PN_PolynI = [0 1 0 0 0 1 1 1 0 1 0 0 0 0 1];  
PN_PolynQ = [0 0 1 1 1 0 0 0 1 1 1 1 0 0 1];

%Define the channel
Antenna_number=4;                                                         % Number of receive antennas
Path_number=8;                                                            % Number of paths  
Path_number_mc=6;
% Path_Gain=[0.8084 0.462 0.253 0.259 0.0447 0.01];                         % Profile of channel model
% delay=[0 18 36  54 72  90]*2;                                             % Delays of paths

Delay_spread=10;                                                           % in us
Path_Gain=exp(-(0:1/(Path_number_mc-1):1)*3*log(10));
Path_Gain=Path_Gain/sqrt(Path_Gain*Path_Gain');
delay=round((0:1/(Path_number_mc-1):1)*Delay_spread*23.04);

% Path_Gain=10.^(([0 -1 -9 -10 -15 -20])/20);                                        % Profile of channel model
% Path_Gain=[Path_Gain/sqrt(Path_Gain*Path_Gain')];
% 
% delay=round([0 0.310 0.710  1.09 1.73  2.51]*23.04);   

Fc = 3.2e9;                                                               % Carrier frequency 
V =250;                                                                   % moving speed in km/h
Tc = 1/1.28e6/Sampling_factor;                                            % Chip width 
Time_Begin = 0;                                                           % Initializing the time
% Phase = 2*pi*rand(1,2);                                                   % Initializing the phase

% Define pilot signal
%Pilot_sequence=[-1 1 j -1 -1 -1 j 1 -1 1 j -1 -1 -1 j 1 -1 1 j -1 -1 -1 j 1];
Pilot_sequence=[1 j 1 -1 1 1 -1 -j 1 -j 1 1 1 -1 -1 j];
%Pilot_sequence=[1 j 1 -1 1 1 -1 -j 1 -j 1 1 1 -1 -1 j     1 j 1 -1 1 1 -1 -j 1 -j 1 1 1 -1 -1 j];

%Pilot_sequence=[ 1  1  1 1  (1-j)/sqrt(2) -1  (1+j)/sqrt(2) -j...
%                 j -1 -j 1  (1+j)/sqrt(2)  1  (1-j)/sqrt(2) -j...
%                -1  1 -1 1 (-1+j)/sqrt(2) -1 (-1-j)/sqrt(2) -j...
%                -j -1  j 1 (-1-j)/sqrt(2)  1 (-1+j)/sqrt(2) -j];
for m=1:Path_number
    Pilot_matrix(m,:)=[Pilot_sequence(Pilot_length-m+2:Pilot_length) Pilot_sequence(1:Pilot_length-m+1)];
end
Gaurd_Pilot=[Pilot_sequence(Pilot_length-Gaurd_length+1:Pilot_length) Pilot_sequence];
Gaurd_Pilot1=[zeros(1,Gaurd_length) Pilot_sequence];

% turbo code
poly_g1 = 11;			% 1 0 1 1
poly_g2 = 13;			% 1 1 0 1
MemLen = 3;
puncture = 0;			% puncture = 0,rate=1/2;puncture = 1,no puncture rate =1/3
nIter = 6;
CodeRate = 1/(2+puncture);
% end

%trel=poly2trellis(9,[561 753]); 
InputN=1; OutputN=2;
%tblen=40;
Slot_number=60;
Symbol_bitN=4;                                                                % 2 for QPSK and 4 for 16QAM
Map_16QAM=[3+j*3 3+j 3-j*3 3-j 1+j*3 1+j 1-j*3 1-j -3+j*3 -3+j -3-j*3 -3-j -1+j*3 -1+j -1-j*3 -1-j]/sqrt(10);
%Map_16QAM=[-1-j -1-3*j -1+j -1+3*j -3-j -3-3*j -3+j -3+3*j 1-j 1-3*j 1+j 1+3*j 3-j 3-3*j 3+j 3+3*j]/sqrt(10);

%msg_L=Symbol_bitN*SlotData_length/OutputN*InputN*Slot_number-InputN*tblen;    % Number of message bits
msg_L=Symbol_bitN*SlotData_length/OutputN*InputN*4-MemLen;    % Number of message bits
code_L=Symbol_bitN*SlotData_length*4;
code_SlotL=Symbol_bitN*SlotData_length;
packet_N=Slot_number*Carrier_number_used/4;

K1=code_L*packet_N/Carrier_number_used/64;
K2=64;
int_table1 = WcdmaTurboInterleaver(K1)';
int_table2 = WcdmaTurboInterleaver(K2)';

for n=1:K2
    int_table((n-1)*K1+1:n*K1)=K1*(int_table2(n)-1)+int_table1;
end

[int_table0] = interleave(msg_L+MemLen, floor(sqrt((msg_L+MemLen)/2)));

Intl_length =Subslot_number;
% Raised cosine filter for interpolation
Interp_factor=3;
rcflt=rcosfir(0.15,6,Interp_factor,1);

% Bit error rate
ber=zeros(3,20);
format long

% Main loop

for Antenna_number=2.^(2:2);                                                         % Number of receive antennas
    
    SNR1=2; SNR2=5;
    
    Phase = 2*pi*rand(Antenna_number,2);                                                   % Initializing the phase
    
    
    for SNR=SNR1:SNR2
        
        errors=0;
        
        for k=1:2000      
            SNR
            k
            
            msg=randint(packet_N,msg_L,2);                                                                               % Random data
            %             msg=[msg zeros(Carrier_number,InputN*tblen)];
            for np=1:packet_N 
                %                 code(nc,:)=convenc(msg(nc,:),trel);                                                                            % Encode
                code_p(np,:) = TuEnc(msg(np,:), puncture, int_table0, poly_g1, poly_g2);
                
                %     code(nc,:)=reshape(vec2mat(code(nc,:),Subslot_number),1,code_L);                                               % Interleaving
            end
            
            code=vec2mat(reshape(code_p,1,code_L*packet_N),code_L*packet_N/Carrier_number_used);
            code=code(:,int_table);
            
            
            for sn=0:Slot_number-1
                % Transmiter
                % Transmiter:Generate single-carrier baseband signals 
                [PN,PN_RegStateI,PN_RegStateQ]=Complex_PNGen(PN_PolynI,PN_PolynQ,PN_RegStateI,PN_RegStateQ,SlotData_length);   % get a complex PN sequence.
                
                for nc=1:Carrier_number_used 
                    s=[]; 
                    
                    

⌨️ 快捷键说明

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