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

📄 mimo_ofdm_transmiter.m

📁 用matlab对MIMO-OFDM通信系统的设计仿真的源代码
💻 M
字号:
function [tx_signal_time,tx_data_pilot]=MIMO_OFDM_transmiter(MIMO_OFDM_system_par)
% Function MIMO_OFDM_transmiter +++++++++++++++++++++++++++++++++++++++++++++++++
% Realize the transmiter of MIMO OFDM system

% Input data:  MIMO_OFDM_system_par - parameters of MIMO OFDM system
% Output data: tx_signal_time - transmit signal of MIMO OFDM system
%             if pulse shaping is disabled,(num_tx_antenna,num_carriers+num_guard_length,num_frame_channel_inv)
%             if pulse shaping is enabled,(num_tx_antenna,(num_carriers+num_guard_length+pulse_delay*2)*pulse_oversampling,num_frame_channel_inv)

% Begin:  Feb, 2005
% Last edited: Feb.28, 2005
%   Feng Wan    

num_frame_channel_inv=MIMO_OFDM_system_par.num_frame_channel_inv;
num_tx_antenna=MIMO_OFDM_system_par.num_tx_antenna;
num_carriers=MIMO_OFDM_system_par.num_carriers;
num_effect_carriers=MIMO_OFDM_system_par.num_effect_carriers;
num_guard_length=MIMO_OFDM_system_par.num_guard_length;
num_pilot=MIMO_OFDM_system_par.num_pilot;
firstnum_pilot=MIMO_OFDM_system_par.firstnum_pilot;
interval_pilot=MIMO_OFDM_system_par.interval_pilot;
modulation_type=MIMO_OFDM_system_par.modulation_type;
pilot_type=MIMO_OFDM_system_par.pilot_type;
pulse_type=MIMO_OFDM_system_par.pulse_type;
if(pulse_type==1)
    pulse_oversampling=MIMO_OFDM_system_par.pulse_oversampling;
    pulse_filt_order=MIMO_OFDM_system_par.pulse_filt_order;
    pulse_rolloff_factor=MIMO_OFDM_system_par.pulse_rolloff_factor;
    pulse_delay=MIMO_OFDM_system_par.pulse_delay;
end
channel_length=MIMO_OFDM_system_par.channel_length;

[tx_data]=generate_tx_data(num_tx_antenna,num_effect_carriers,modulation_type,num_frame_channel_inv);

% % test the independent property of the information signals in frequency domain
% Rxx_real_effect=zeros(num_tx_antenna);
% for n1=1:num_tx_antenna
%     for n2=1:num_tx_antenna
%         rxx_temp=0;
%         for n3=1:num_effect_carriers
%             rxx_temp=rxx_temp+tx_data(n1,n3,1)*conj(tx_data(n2,n3,1));
%         end
%         Rxx_real_effect(n1,n2)=rxx_temp/num_effect_carriers;
%     end
% end


%+++++++++++++++++++++++++++++++++++++++++++ 
% adding pilot
%+++++++++++++++++++++++++++++++++++++++++++ 
tx_data_pilot=zeros(num_tx_antenna,num_carriers,num_frame_channel_inv);
switch pilot_type
    case 1 % the pilots of different frames are in the same locations 
        [mat_pilot]=generate_opt_pilot(num_tx_antenna,num_pilot*num_frame_channel_inv,channel_length);
        for n1=1:num_frame_channel_inv
            tx_data_pilot(:,firstnum_pilot:interval_pilot:num_carriers,n1)=mat_pilot...
                (:,n1:num_frame_channel_inv:num_pilot*num_frame_channel_inv);
        end
        if(firstnum_pilot~=1)
              tx_data_pilot(:,1:firstnum_pilot-1,:)=tx_data(:,1:firstnum_pilot-1,:);
        end
        temp_pre=firstnum_pilot-1;
        for n1=1:num_pilot-1
            tx_data_pilot(:,temp_pre+2+(n1-1)*interval_pilot:temp_pre+n1*interval_pilot,:)=...
                tx_data(:,temp_pre+(n1-1)*(interval_pilot-1)+1:temp_pre+n1*(interval_pilot-1),:);
        end
        if(temp_pre+num_pilot*interval_pilot+1~=num_carriers)
            tx_data_pilot(:,temp_pre+(num_pilot-1)*interval_pilot+2:num_carriers,:)=...
                tx_data(:,temp_pre+(num_pilot-1)*(interval_pilot-1)+1:num_effect_carriers,:);
        end

    case 2 % the pilots of different frames are not in the same locations
        error('Error! pilot_type=2 is not defined! Choose it from (1--1)!');
end

% % test the independent property of the signals in frequency domain
% Rxx_real=zeros(num_tx_antenna);
% for n1=1:num_tx_antenna
%     for n2=1:num_tx_antenna
%         rxx_temp=0;
%         for n3=1:num_carriers
%             rxx_temp=rxx_temp+tx_data_pilot(n1,n3,1)*conj(tx_data_pilot(n2,n3,1));
%         end
%         Rxx_real(n1,n2)=rxx_temp/num_carriers;
%     end
% end

%+++++++++++++++++++++++++++++++++++++++++++ 
% OFDM modulation
%+++++++++++++++++++++++++++++++++++++++++++ 

tx_data_pilot_time=zeros(num_tx_antenna,num_carriers+num_guard_length,num_frame_channel_inv);
for n1=1:num_frame_channel_inv
    for n2=1:num_tx_antenna
        [temp_vec]=OFDM_modulator(tx_data_pilot(n2,:,n1),num_guard_length);
        tx_data_pilot_time(n2,:,n1)=temp_vec;
    end
end

% % test the independent property of the signals in time domain including cyclic prefix
% Rxx_real_time_cyc=zeros(num_tx_antenna);
% for n1=1:num_tx_antenna
%     for n2=1:num_tx_antenna
%         rxx_temp=0;
%         for n3=1:num_carriers+num_guard_length
%             rxx_temp=rxx_temp+tx_data_pilot_time(n1,n3,1)*conj(tx_data_pilot_time(n2,n3,1));
%         end
%         Rxx_real_time_cyc(n1,n2)=rxx_temp/num_carriers;
%     end
% end

% % test the independent property of the signals in time domain without cyclic prefix
% Rxx_real_time=zeros(num_tx_antenna);
% for n1=1:num_tx_antenna
%     for n2=1:num_tx_antenna
%         rxx_temp=0;
%         for n3=num_guard_length+1:num_carriers+num_guard_length
%             rxx_temp=rxx_temp+tx_data_pilot_time(n1,n3,1)*conj(tx_data_pilot_time(n2,n3,1));
%         end
%         Rxx_real_time(n1,n2)=rxx_temp/num_carriers;
%     end
% end


% tx_data_pilot_time=zeros(num_frame_channel_inv,num_tx_antenna,num_carriers+num_guard_length);
% for n1=1:num_frame_channel_inv
%     for n2=1:num_tx_antenna
%         [temp_vec]=OFDM_modulator(tx_data_pilot(n1,n2,:),num_guard_length);
%         tx_data_pilot_time(n1,n2,:)=temp_vec;
%     end
% end

%+++++++++++++++++++++++++++++++++++++++++++ 
% pulse shaping filter
%+++++++++++++++++++++++++++++++++++++++++++ 

if(pulse_type==1)
    % Create a square root raised cosine filter.
    pulse_rrcfilter=rcosine(1,pulse_oversampling,'fir/sqrt',pulse_rolloff_factor,pulse_delay);

    % Upsample and apply square root raised cosine filter.
    tx_signal=zeros(num_tx_antenna,(num_carriers+num_guard_length+pulse_delay*2)*pulse_oversampling,num_frame_channel_inv);
%     tx_vec_temp=zeros(num_carriers+num_guard_length);
    for n1=1:num_frame_channel_inv
        for n2=1:num_tx_antenna
            tx_vec_temp=tx_data_pilot_time(n2,:,n1).';
%             for n3=1:num_carriers+num_guard_length
%                 tx_vec_temp(n3)=tx_data_pilot_time(n2,n3,n1);
%             end
            tx_vec_temp2=rcosflt(tx_vec_temp,1,pulse_oversampling,'filter',pulse_rrcfilter);
            tx_data_pulsed_time(n2,:,n1)=tx_vec_temp2.';
        end
    end
else
    tx_data_pulsed_time=tx_data_pilot_time;
end
tx_signal_time=tx_data_pulsed_time;


⌨️ 快捷键说明

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