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

通讯编程

开发平台:

Matlab

  1. function [symbol_sequence,bit_sequence]=rx_combine(rx,channel,use_relay,Ps);
  2. %在接收端合并两路信号,并判决出发送信号序列
  3. global signal;
  4. global relay;
  5. values2analyse=rx.signal2analyse;
  6. if (use_relay==1)&(relay.magic_genie==1)
  7.     switch relay.mode
  8.         case 'DAF'
  9.             values2analyse(2,:)=(relay.symbol_sequence==signal.symbol_sequence).*values2analyse(2,:);
  10.         otherwise
  11.             error(['Magic genie work only with DAF'])
  12.     end
  13. end
  14. switch rx.combining_type
  15.     case 'MRC'
  16.         switch relay.mode
  17.             case 'DAF'
  18.                 if (use_relay==0)
  19.                     h=conj(channel(1).attenuation.h);
  20.                 else
  21.                     h=conj([channel(1).attenuation.h;channel(3).attenuation.h]);
  22.                 end
  23.                 bit_sequence=(mean(symbol2bit(h.*values2analyse),1)>=0)*2-1;
  24.             case 'AAF'
  25.                 if (use_relay==0)
  26.                     h=conj(channel(1).attenuation.h);
  27.                 else
  28.                     
  29.                     h=conj([channel(1).attenuation.h;channel(3).attenuation.h.*channel(2).attenuation.h]);
  30.                 end
  31.                 bit_sequence=(mean(symbol2bit(h.*values2analyse),1)>=0)*2-1;     
  32.             otherwise
  33.                 error(['error!']);
  34.         end
  35.     case{'ERC','FRC','SNRC','ESNRC'}
  36.         values2analyse=symbol2bit(values2analyse);
  37.         switch rx.combining_type
  38.             case 'ERC'
  39.                 bit_sequence=(mean(values2analyse,1)>=0)*2-1;
  40.             case 'FRC'
  41.                 if (use_relay==0)
  42.                     bit_sequence=(mean(values2analyse,1)>=0)*2-1;
  43.                 else
  44.                     bit_sequence=(mean([rx.sd_weight;1]*ones(1,size(values2analyse,2)).*values2analyse)>=0)*2-1;
  45.                 end
  46.             case {'SNRC','ESNRC'}
  47.                 if (use_relay==0)
  48.                     bit_sequence=(mean(values2analyse,1)>=0)*2-1;
  49.                 else
  50.                     SNR_direct=estimate_direct_channel_SNR(channel(1),signal.modulation_type,Ps);
  51.                     SNR_via=estimate_via_channel_SNR(channel(2),channel(3),relay.mode,Ps);
  52.                     if (signal.modulation_type=='QPSK')
  53.                         SNR_via=[SNR_via,SNR_via];
  54.                     end
  55.                     switch rx.combining_type
  56.                         case 'SNRC'
  57.                             bit_sequence=(mean([SNR_direct;SNR_via].*values2analyse,1)>=0)*2-1;
  58.                         case 'ESNRC'
  59.                             use_direct=SNR_direct./SNR_via>10;
  60.                             use_via=SNR_direct./SNR_via<0.1;
  61.                             use_equal_ratio=not(use_direct+use_via);
  62.                             bit_sequence_equal_ratio=(mean(values2analyse,1)>=0)*2-1;
  63.                             bit_sequence_direct=(values2analyse(1,:)>=0)*2-1;
  64.                             bit_sequence_via=(values2analyse(2,:)>=0)*2-1;
  65.                             bit_sequence=use_equal_ratio.*bit_sequence_equal_ratio+use_direct.*bit_sequence_direct+use_via.*bit_sequence_via;
  66.                     end
  67.                 end
  68.             otherwise
  69.             error(['Combining-type unkonwn:',rx.combining_type])
  70.         end
  71. end
  72. symbol_sequence=bit2symbol(bit_sequence);
  73.         
  74.                  
  75.                     
  76.                     
  77.                 
  78.                 
  79.         
  80.         
  81.