• 大小: 9KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-05
  • 语言: Matlab
  • 标签: OFDM  信道估计  

资源简介

OFDM系统信道估计matlab仿真程序

资源截图

代码片段和文件信息

%OFDM Channel Estimation based on Comb Pilot
%IFFT_bin_length: IFFT和FFT的点数
%carrier_count: 子载波个数
%bits_per_symbol: 每符号上的比特数
%symbols_per_carrier: 每桢的OFDM符号数
%X:欲发送的二进制比特流

clear all;
clc;
IFFT_bin_length=128;  %IFFT_bin_length: IFFT和FFT的点数
carrier_count=100;    %carrier_count: 子载波个数
bits_per_symbol=2;    %bits_per_symbol: 每符号上的比特数
symbols_per_carrier=12;    %symbols_per_carrier: 每桢的OFDM符号数
LI=7 ; %导频之间的间隔
Np=ceil(carrier_count/LI)+1;%导频数 %加1的原因:使最后一列也是导频 %%ceil的用法:取最接近A但是大于等于A的整数结果取整不保留小数部分
N_number=carrier_count*symbols_per_carrier*bits_per_symbol;
carriers=1:carrier_count+Np;%相当于将载波标号一一列出

GI=8;             % guard interval length
N_snr=40;          % 每比特信噪比
snr=8;             %信噪比间隔
%------------------------------------------------------------
% vector initialization


X=zeros(1N_number);
X1=[];
X2=[];
X3=[];
X4=[];
X5=[];
X6=[];
X7=[];
Y1=[];
Y2=[];
Y3=[];
Y4=[];
Y5=[];
Y6=[];
Y7=[];
XX=zeros(1N_number);
dif_bit=zeros(1N_number);
dif_bit1=zeros(1N_number);
dif_bit2=zeros(1N_number);
dif_bit3=zeros(1N_number);
X=randint(1N_number);%产生二进制随即序列(非0即1)
%--------------------------------------------------------
%QPSK调制:(1 1)->pi/4;(0 1)->3*pi/4;(0 0)->-3*pi/4;(10)->-pi/4;

s=(X.*2-1)/sqrt(2);%分子转化成双极性
sreal=s(1:2:N_number);
simage=s(2:2:N_number);
X1=sreal+1i.*simage;%QPSK调制后的信号

%---------------------------------------------------------
%产生随机导频信号
%--------------------------------------------------------
train_sym=randint(12*symbols_per_carrier);
t=(train_sym.*2-1)/sqrt(2);
treal=t(1:2:2*symbols_per_carrier);
timage=t(2:2:2*symbols_per_carrier);
training_symbols1=treal+1i.*timage;
training_symbols2=training_symbols1.‘;
training_symbols=repmat(training_symbols21Np);%%repmat表示复制矩阵training_symbols2成1行Np列(把矩阵training_symbols2当成一个元素)

%disp(training_symbols)tt
pilot=1:LI+1:carrier_count+Np;
if length(pilot)~=Np%导频数
    pilot=[pilotcarrier_count+Np];
end
%--------------------------------------------------------
%串并转换
X2=reshape(X1carrier_countsymbols_per_carrier).‘;%%reshape表示变化矩阵X1将其按照carrier_count(数量)行symbols_per_carrier(数量)列存储
%---------------------------------------------------------
%插入导频
signal=1:carrier_count+Np;
signal(pilot)=[];
X3(:pilot)=training_symbols;
X3(:signal)=X2;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%为什么有重复赋值
%X3=cat(1training_symbolsX2);%排列成[training_symbols;X2]
IFFT_modulation=zeros(symbols_per_carrierIFFT_bin_length);
IFFT_modulation(:carriers)=X3;
%IFFT_modulation(:conjugate_carriers)=(X3);
X4=ifft(IFFT_modulationIFFT_bin_length2);%y = ifft(Xndim)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%为什么要ifft
%X5=X4.‘;
%加保护间隔(循环前缀)
for k=1:symbols_per_carrier;
   for i=1:IFFT_bin_length;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%起点应该是GI
      X6(ki+GI)=X4(ki);
   end
   for i=1:GI;
      X6(ki)=X4(ki+IFFT_bin_length-GI);    
   end
end
%---------------------------------------------------------
%并串转换
X7=reshape(

评论

共有 条评论