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

📄 mimo_ch.m

📁 3gpp2信道模型,8个matlab源代码
💻 M
字号:
function Channel_H = mimo_ch(Tx_n, Rx_n, Path_n, fc, v, fs, time_slot, Channel_n)
% 衰落信道程序(jakes)
% usage: Channel_H = mimo_ch(1, 1, 2, 900, 150, 250000, 2000,1)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Tx_n : the Tx antenna number
% Rx_n : the Rx antenna number
% Path_n : multipath except the main path
% fc: the carrier frequency.( MHz )
% v:  the speed of vehicle.( Km/h )
% fs: the sample frequency.(Hz)
% time_slot: the time duration
% Channel_n : the realization number of channel
% must agree that time_slot*fmax>=Q; if Q=0, and Path_n=0 then it is the flat fading.
% if Path_n=0, then it is the time-selective channel
% if Q=0, then it is the frequency-selective channel

% Last updated by HYM on 05/18/2006
%    reference: Simulation Models With Correct Statistical Properties for
%    Rayleigh Fading Channels, IEEE TRANSACTION ON COMMUNICATION, VOL.51,
%    NO.6, JUNE 2003


i = sqrt(-1);
c=3e8;

%******* for debug ******
% Tx_n=1;
% Rx_n=1;
% Path_n=2;
% fc=900;
% v=50;
% fs=10000;
% time_slot=500;
% Channel_n=1;
%****** for debug *******

fmax=fc*v/c*1e6*1e3/3600
% Power_profile = sqrt(exp(-[0:Path_n]/2));
% Power_profile=Power_profile/norm(Power_profile);
Power_profile=ones(1,Path_n+1);
if fmax > 0
    file = sprintf('MIMO_T%dR%dFc%dP%dV%dFs%dN%dC%d',Tx_n, Rx_n, fc, Path_n, v, fs, time_slot, Channel_n);
    N = 8;
    
    while(N)
        if (N < 2*fmax*time_slot/fs)
            N = 2*N;
        else
            break;
        end
    end
    
%     N = 20;
    N
%     fd = cos(2*pi*((1:N)/N))*fmax; % Generating uniformly spaced
    for realization = 1:Channel_n
        for tx = 1 : Tx_n
            for rx = 1 : Rx_n
                for path = 1 : Path_n+1
                    rand('state',sum(100*clock));
                    psi=2*pi*(rand(1,N)-0.5);               % generate the independent and uniformly distributed parameters defined in the model
                    theta=2*pi*(rand(1,1)-0.5);
                    alpha=(2*pi.*[1:N]-pi+theta)./(4*N);
                    phi=2*pi*(rand(1,1)-0.5);
                    for t=1:time_slot
                        real_time=t/fs;
                        one_tv_link(t)=sqrt(2/N).*complex(sum(cos(psi).*cos(2*pi*t*fmax.*cos(alpha)+phi)),sum(sin(psi).*cos(2*pi*t*fmax.*cos(alpha)+phi)));
                    end

                    Channel_H(rx, tx, path, :, realization) = one_tv_link * Power_profile(path);
                    % add up the value of all path for different time_slot point
                    % result = result+one_tv_link*Power_profile(path)/sqrt(N);
                end
            end
        end
        if(mod(realization,50) == 0)
            fprintf(1, '.');
        end
        if(mod(realization,2000) == 0)
            fprintf(1,'\n');
        end
    end
elseif fmax == 0
    % generate frequency-selective channel or flat fading channel
    file = sprintf('MIMO_flat_T%dR%dFc%dP%dD%dN%dC%d',Tx_n, Rx_n, fc, Path_n, fmax, time_slot, Channel_n);
    for realization = 1:Channel_n
        for tx = 1 : Tx_n
            for rx = 1 : Rx_n
                for path = 1 : Path_n+1
                    one_tv_link = (randn(1,1)+j*randn(1,1))/sqrt(2).*ones(1,time_slot)*Power_profile(path);
                    Channel_H(rx, tx, path, :, realization) = one_tv_link;
                end
            end
        end
        if(mod(realization,50) == 0)
            fprintf(1, '.');
        end
        if(mod(realization,2000) == 0)
            fprintf(1,'\n');
        end
    end
else
    fprintf(1,'error Dopplor');
end
% tv_link= Channel_H(1,1,1,:,1);
% tv_link=tv_link(:);

% plot(real(tv_link),'r-');
% hold on
% plot(imag(tv_link),'b:');
% title(['fc= ' num2str(fc) 'MHz    V= ' num2str(v)]);
% figure

% plot(10*log10(abs(tv_link)));
% title(['fc= ' num2str(fc) 'MHz    V= ' num2str(v) 'Km/h   Ts= ' num2str(1/fs*1e6) 'us']);

% hist(abs(tv_link),20);
%mean(10*log10(abs(tv_link).^2))

% save(file, 'Channel_H', 'Tx_n', 'Rx_n' ,'Path_n', 'fc' ,'v' ,'fs',
% 'time_slot');

⌨️ 快捷键说明

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