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

通讯编程

开发平台:

Matlab

  1. function [channel,rx,a,noise_vector]=add_channel_muti_effect(channel,rx,signal_sequence,P);
  2. %信道影响函数,并且能够找到信道增益与噪声方差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(P*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. a=channel.attenuation.h_mag.*channel.attenuation.h_mag/(2*channel.noise.sigma);%用来为功率分配用
  32.         
  33.         
  34.