add_channel_effect_noNoise.m
上传用户:cjx922
上传日期:2017-12-13
资源大小:205k
文件大小:2k
源码类别:

通讯编程

开发平台:

Matlab

  1. function [channel,rx]=add_channel_effect_noNoise(channel,rx,signal_sequence);
  2. %信道影响函数
  3. global signal;
  4. channel.attenuation.d=1/(channel.attenuation.distance^2);%pass loss is constant for the whole transmittion
  5. switch channel.attenuation.pattern
  6.     case 'no'  %no fading at all(only pass loss)
  7.         channel.attenuation.phi=zeros(size(signal_sequence));
  8.         channel.attenuation.h=ones(size(signal_sequence))*channel.attenuation.d;
  9.         channel.attenuation.h_mag=channel.attenuation.h;   
  10.     case 'Rayleigh'%Rayleigh
  11.         nr_of_blocks=ceil(size(signal_sequence,2)/channel.attenuation.block_length);
  12.         h_block=(randn(nr_of_blocks,1)+j*randn(nr_of_blocks,1))*channel.attenuation.d;
  13.         h=reshape((h_block*ones(1,channel.attenuation.block_length))',1,nr_of_blocks*channel.attenuation.block_length);
  14.         channel.attenuation.h=h(1:(size(signal_sequence,2)));
  15.         [channel.attenuation.phi,channel.attenuation.h_mag]=cart2pol(real(channel.attenuation.h),imag(channel.attenuation.h));
  16.         channel.attenuation.phi=-channel.attenuation.phi;
  17.     otherwise
  18.         error(['Fading pattern unknown:',channel.attenuation.pattern])
  19. end
  20. %加性高斯白噪声
  21. if (size(signal_sequence,2)~=0)
  22.     S=mean(abs(signal_sequence).^2);
  23. else
  24.     S=0;
  25. end
  26. SNR_linear=10^(channel.noise.SNR/10);
  27. channel.noise.sigma=sqrt(S/(2*SNR_linear));
  28. noise_vector=(randn(size(signal_sequence))+j*randn(size(signal_sequence)))*channel.noise.sigma;
  29. %把衰落和加性高斯白噪声作用于信号,得到接收信号
  30. rx.received_signal=signal_sequence.*channel.attenuation.h;
  31.         
  32.         
  33.