channel.m
来自「it is very good codes for space-time sys」· M 代码 · 共 50 行
M
50 行
function varargout = channel(sig,temp,fading,snr,sim_options)
%**************************************************************************
%CHANNEL MIMO channel model.
% Y = CHANNEL(X) corrupts input signal X by desired type of channel
% fading.
%**************************************************************************
ch_conf=[2 sim_options.RxDiv];
[sig_length,space_dim,frames] = size(sig);
spowr=sum(abs(sig(:,1,1)))/sig_length;
sigma =sqrt(0.5*spowr* (10 ^ (0.1 *- snr)));
const = sqrt(2);
switch fading
case 'Rayleigh'
ch_coefs = (randn(ch_conf(1),ch_conf(2),frames) +...
i * randn(ch_conf(1),ch_conf(2),frames))/const ;
ch_noise = (randn(sig_length+temp,ch_conf(2),frames) +...
i * randn(sig_length+temp,ch_conf(2),frames)) * sigma ;
case 'AWGN'
ch_coefs = ones(ch_conf(1),ch_conf(2),frames);
ch_noise = (randn(sig_length+temp,space_dim,frames) +...
i * randn(sig_length+temp,space_dim,frames)) * sigma;
end
if temp
temp1=sig;
sig=[zeros(20,2,frames); sig];
temp=[];
pilots=[0 0 0 0 0 0 0 0 0 0 1 -1 -1 1 -1 -1 1 -1 1 1;1 -1 -1 -1 1 -1 -1 1 -1 1 0 0 0 0 0 0 0 0 0 0];
for k=1:frames
sig(:,:,k)=[pilots.'; temp1(:,:,k)];
end
end
% signal mixture
for k = 1:frames % no 3D arrays multiplication is available
sig_add(:,:,k) = sig(:,:,k) * ch_coefs(:,:,k);
end
sig_corr = (sig_add + ch_noise);
varargout = {sig_corr,ch_coefs};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?