www.gusucode.com > OFDM_16QAM系统仿真源码程序 > OFDM_16QAM系统仿真源码程序/code/channel_model.m

    
function channel_response = channel_model(option,f_max,N_sim,T_s,T_start)

% Multipath channel model for indoor environment, assuming the channel response is invariant within one frame
% The sampling rate is 20Msps and a threshold level of 20dB below the maximum

% if option = 1, Small office/ Home office enviorment, and the rms delay spread is 0.05us, model tap is 5
% if option = 2, Large office building enviorment, the rms delay spread is 0.1us, model tap is 10
% if option = 3, Factory enviorment, the rms delay spread is 0.2us, model tap is 19

% In the indoor environment, the delay power spectral density is modeled by the classical Jakes power spectral density

% Paramters referred:
% f_max: Maximum Doppler frequency
% N_sim: Simulation time number
% T_s: Channel sampling interval
% T_start: Simulation starting time

% var_rms: rms delay spread
% alp: exponent of the power delay profile
% L : number of multipath 
% a(l): delay coefficients of the lth delay path 
% t_max: the largest delayed considered, for t > t_max, the delay power is under the threshold and not taken into consideration
% P_thresh: delay power threshold

% Channel parameter calculation %
fs = 20e6;                             % Signal sampling rate, 20MHz
P_thresh = 30;                          % Threshold lever, in dB
%option = 1;
%f_max = 91;
%N_sim = 1e2;
%T_s = 4*10^(-6);
%T_start = 4*10^(-6);
if option == 1
    fprintf('Simulation is performed assuming the small office/ home office environment.\n');
    var_rms = 50 * 10^(-9);             % Rms delay spread is 50nsec
    L = 5;
else if option ==2
        fprintf('Simulation is performed assuming the large office building environment.\n');
        var_rms = 100 * 10^(-9);        % Rms delay spread is 100nsec
        L = 10;
    else 
        fprintf('Simulation is performed assuming the factory environment.\n');
        var_rms = 200 * 10^(-9);        % Rms delay spread is 200nsec
        L = 19;
    end
end

alp = -2 * fs * log( sqrt( 1 + 1/( 2 * fs * var_rms )^2 ) - 1/( 2 * fs * var_rms));
P_thresh = 10^(P_thresh/10);            % Change dB into linear metric
t_max = log(P_thresh)/alp;              %  P(t) = alp * exp(-alp * t)
t1=0;
t2=0;
for l = 1 : L
    if l == 1
        T1 = 0;
        T2 = 1/fs/2;
    else if l == L
            T1 = 1/fs * (L-1) - 1/fs/2;
            T2 = t_max;
        else 
            T1 = 1/fs * (l-1) - 1/fs/2;
            T2 = 1/fs * (l-1) + 1/fs/2;
        end
    end
    a(l) = exp(-alp * T1) - exp(-alp * T2);
end

% Frequency selective Rayleigh fading channel model %

% Each path is assumed Jakes power spectrum 
N_i = 1e2;
for l = 1:L
    [f1,c1,th1] = channel_parameter_Jakes(f_max,N_i);
    [f2,c2,th2] = channel_parameter_Jakes(f_max,N_i+1);                              % Jakes parameter calculation
    channel_response(l,:) = channel_Rayleigh(f1,c1,th1,f2,c2,th2,N_sim,T_s,T_start); % Rayleigh fading of each path 
    channel_response(l,:) = sqrt(a(l)) * channel_response(l,:);              % Multiplied by delay coefficients
    N_i = N_i + 2;                                                           % To assure path independance
end

% For program test only 
%z = [0:0.05:5];
%temp = abs(channel_response(1,:));
%p_z=pdf_sim(temp,z,1);
%title('Rayleigh 分布');