⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mqam_comp.m

📁 使用matlab实现ofdm经过PA后在接收端进行失真抵消算法的仿真
💻 M
📖 第 1 页 / 共 2 页
字号:
    %初始化失真信号
    distortion = zeros( size(y_rx) );
    %初始化迭代变量
    y_rx_temp = ( y_rx - distortion ) / a_ideal;
    
    for it = 1 : iteras
      %重新模拟OFDM接收端解调===============================================
      %对接收到的数据进行并串转换
      b_rx = reshape( y_rx_temp, nsamp * N, P );
      %进行FFT运算
      s_rx = fft( b_rx );
      %进行去零操作
      s_rx = [ s_rx( 1 : N / 2, : ); s_rx( nsamp * N - N / 2 + 1: nsamp * N, : ) ];
      %对这些数据进行并串转换,作为MQAM解调的输入
      x_maqm_out_rx = reshape( s_rx, prod(size(s_rx)), 1 );
      %对输入的数据进行解调
      x_maqm_in_rx = demodulate( modem.qamdemod(M), x_maqm_out_rx );
      
      %重新模拟OFDM发送端调制===============================================
      %对MQAM的输入进行调制
      x_maqm_out_tx = modulate( modem.qammod(M), x_maqm_in_rx );
      %对MQAM的输出每N个为一组进行串并转换,以便进行IFFT
      s_tx  = reshape( x_maqm_out_tx, N, P );
      %频域内插0
      s_tx_up   = s_tx( 1 : (N / 2), :);                  
      s_tx_down = s_tx( (N / 2) + 1 : N, :);
      s_tx      = [ s_tx_up; insert_zeros; s_tx_down ];
      %进行IFFT运算
      b_tx  = ifft( s_tx ); 
      %对IFFT运算后的数据进行并串转换
      y_tx  = reshape( b_tx, prod(size(b_tx)), 1 );
      
      %修改迭代变量=========================================================
      for its = 1 : length( y_tx )
        if abs(y_tx(its)) >= A
          y_rx_temp(its) = y_tx(its);
        end
      end
    end
    
    %获取计算得到的数据
    y_rx = y_rx_temp;
    %对接收到的数据进行并串转换
    b_rx = reshape( y_rx, nsamp * N, P );
    %进行FFT运算
    s_rx = fft( b_rx );
    %进行去零操作
    s_rx = [ s_rx( 1 : N / 2, : ); s_rx( nsamp * N - N / 2 + 1: nsamp * N, : ) ];
    %对这些数据进行并串转换,作为MQAM解调的输入
    x_maqm_out_rx = reshape( s_rx, prod(size(s_rx)), 1 );
    %对输入的数据进行解调
    x_maqm_in_rx = demodulate( modem.qamdemod(M), x_maqm_out_rx );
    %对解调后的数据还原为原来的二进制位
    x_rx  = reshape( (de2bi(x_maqm_in_rx, 'left-msb'))', n, 1 );
  
    %误比特率
    [ e_num, e_rate(step) ] = biterr( x_maqm_in_tx, x_maqm_in_rx );
  end
  %画出误码率曲线
  semilogy( EbNo, e_rate, '-^k');
end


if  pro(4) == 1
  %OFDM失真不动点补偿基带解调=============================================================
  for step = 1 : snr_range
    %OFDM信号接收处理
    y_rx = ydis_noisy(:, step);
    %松弛变量
    nda = 1 / a_ideal;
    %初始化迭代变量
    y_rx_temp = y_rx / a_ideal;
    
    for it = 1 : iteras
      %重新模拟OFDM接收端解调===============================================
      %对接收到的数据进行并串转换
      b_rx = reshape( y_rx_temp, nsamp * N, P );
      %进行FFT运算
      s_rx = fft( b_rx );
      %进行去零操作
      s_rx = [ s_rx( 1 : N / 2, : ); s_rx( nsamp * N - N / 2 + 1: nsamp * N, : ) ];
      %对这些数据进行并串转换,作为MQAM解调的输入
      x_maqm_out_rx = reshape( s_rx, prod(size(s_rx)), 1 );
      %对输入的数据进行解调
      x_maqm_in_rx = demodulate( modem.qamdemod(M), x_maqm_out_rx );
      
      %重新模拟OFDM发送端调制===============================================
      %对MQAM的输入进行调制
      x_maqm_out_tx = modulate( modem.qammod(M), x_maqm_in_rx );
      %对MQAM的输出每N个为一组进行串并转换,以便进行IFFT
      s_tx  = reshape( x_maqm_out_tx, N, P );
      %频域内插0
      s_tx_up   = s_tx( 1 : (N / 2), :);                  
      s_tx_down = s_tx( (N / 2) + 1 : N, :);
      s_tx      = [ s_tx_up; insert_zeros; s_tx_down ];
      %进行IFFT运算
      b_tx  = ifft( s_tx ); 
      %对IFFT运算后的数据进行并串转换
      y_rx_temp  = reshape( b_tx, prod(size(b_tx)), 1 );

      %迭代操作
      y_rx_temp = nda * y_rx + y_rx_temp - nda * pa_nonlinear(y_rx_temp, A);
    end
    
    %获取计算得到的数据
    y_rx = y_rx_temp;
    %对接收到的数据进行并串转换
    b_rx = reshape( y_rx, nsamp * N, P );
    %进行FFT运算
    s_rx = fft( b_rx );
    %进行去零操作
    s_rx = [ s_rx( 1 : N / 2, : ); s_rx( nsamp * N - N / 2 + 1: nsamp * N, : ) ];
    %对这些数据进行并串转换,作为MQAM解调的输入
    x_maqm_out_rx = reshape( s_rx, prod(size(s_rx)), 1 );
    %对输入的数据进行解调
    x_maqm_in_rx = demodulate( modem.qamdemod(M), x_maqm_out_rx );
    %对解调后的数据还原为原来的二进制位
    x_rx  = reshape( (de2bi(x_maqm_in_rx, 'left-msb'))', n, 1 );
  
    %误比特率
    [ e_num, e_rate(step) ] = biterr( x_maqm_in_tx, x_maqm_in_rx );  
  end
  %画出误码率曲线
  semilogy( EbNo, e_rate, '-^k');
end


if  pro(5) == 1
  %OFDM失真不动点加速补偿基带解调=============================================================
  for step = 1 : snr_range
    %OFDM信号接收处理
    y_rx = ydis_noisy(:, step);
    %松弛变量
    nda = 1 / a_ideal;
    no = 0.05 / 1.85;
    %初始化迭代变量
    y_rx_temp = y_rx / a_ideal;
    
    for it = 1 : iteras
      %重新模拟OFDM接收端解调===============================================
      %对接收到的数据进行并串转换
      b_rx = reshape( y_rx_temp, nsamp * N, P );
      %进行FFT运算
      s_rx = fft( b_rx );
      %进行去零操作
      s_rx = [ s_rx( 1 : N / 2, : ); s_rx( nsamp * N - N / 2 + 1: nsamp * N, : ) ];
      %对这些数据进行并串转换,作为MQAM解调的输入
      x_maqm_out_rx = reshape( s_rx, prod(size(s_rx)), 1 );
      %对输入的数据进行解调
      x_maqm_in_rx = demodulate( modem.qamdemod(M), x_maqm_out_rx );
      
      %重新模拟OFDM发送端调制===============================================
      %对MQAM的输入进行调制
      x_maqm_out_tx = modulate( modem.qammod(M), x_maqm_in_rx );
      %对MQAM的输出每N个为一组进行串并转换,以便进行IFFT
      s_tx  = reshape( x_maqm_out_tx, N, P );
      %频域内插0
      s_tx_up   = s_tx( 1 : (N / 2), :);                  
      s_tx_down = s_tx( (N / 2) + 1 : N, :);
      s_tx      = [ s_tx_up; insert_zeros; s_tx_down ];
      %进行IFFT运算
      b_tx  = ifft( s_tx ); 
      %对IFFT运算后的数据进行并串转换
      y_rx_temp  = reshape( b_tx, prod(size(b_tx)), 1 );
      
      nda = 1 / ( 1 - no ^ 2 * nda / 4);
      
      if it == 1
        y_rx_iteras(:, it) = y_rx_temp;
        y_rx_temp = 2 / 1.85 * y_rx_iteras(:, it);
      else
        %迭代操作,y_rx_iteras(:, it)相当于x(it - 1),y_rx_temp相当于x(it)
        y_rx_iteras(:, it) = y_rx_temp;
        y_rx_temp = nda * ( y_rx_iteras(:, 2) + y_rx_iteras(:, it) - y_rx_iteras(:, it - 1) - pa_nonlinear(y_rx_iteras(:, it), A) * 2 / 1.85 ) + y_rx_iteras(:, it - 1);
      end
    end
    
    %获取计算得到的数据
    y_rx = y_rx_temp;
    %对接收到的数据进行并串转换
    b_rx = reshape( y_rx, nsamp * N, P );
    %进行FFT运算
    s_rx = fft( b_rx );
    %进行去零操作
    s_rx = [ s_rx( 1 : N / 2, : ); s_rx( nsamp * N - N / 2 + 1: nsamp * N, : ) ];
    %对这些数据进行并串转换,作为MQAM解调的输入
    x_maqm_out_rx = reshape( s_rx, prod(size(s_rx)), 1 );
    %对输入的数据进行解调
    x_maqm_in_rx = demodulate( modem.qamdemod(M), x_maqm_out_rx );
    %对解调后的数据还原为原来的二进制位
    x_rx  = reshape( (de2bi(x_maqm_in_rx, 'left-msb'))', n, 1 );
  
    %误比特率
    [ e_num, e_rate(step) ] = biterr( x_maqm_in_tx, x_maqm_in_rx );  
  end
  %画出误码率曲线
  semilogy( EbNo, e_rate, '-^k');
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -