www.pudn.com > space-timecodingBrankaVuceticJinhongYuan.rar > channel.m, change:2006-12-31,size:1415b


function varargout = channel(sig,temp,fading,snr,RxDiv) 
 
%************************************************************************** 
%CHANNEL MIMO channel model. 
%   Y = CHANNEL(X) corrupts input signal X by desired type of channel 
%   fading.  
%************************************************************************** 
 
 
ch_conf=[2 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};