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

资源简介

ofdm完整的收发程序,包括编码,调制,接收,补偿等

资源截图

代码片段和文件信息

%%scr 

close all;
clear all;

Nfft=128*2;                          %256个子载波 进行256点的FFT
Ng=0;%32*2;                             %64cp
Nzero=0;
Nzerosub=floor((Nfft*0.5)/2);        %for padding       

Ntotal=Ng+2*Nzero+Nfft;              %320
Constellation_num=16;%%星座图
Symbol_num=1;%20;                       %able
N=Symbol_num*Nfft;                   %total 所有帧所有点
Ns=Symbol_num*Ntotal;

Pnum_least(1:Symbol_num)=10000;
Pnum(1:Symbol_num)=0;


Ndata_o=Symbol_num*(Nfft/2-Nfft/16/2);

sita=0;
sita1=1;
sita2=0;
sita3=0; % 测试变量

sign=1;

%for filter
LHBF1=23; % 半带滤波器长度


% I1=zeros(1Ndata_o);
% I2=zeros(1Ndata_o);
% I3=zeros(1Ndata_o);
% I4=zeros(1Ndata_o);


CHBF1(1:LHBF1)=0;
InsertGIout(1:Symbol_num1:Ntotal)=0;

% 半带滤波器系数
fid2=fopen(‘HBF23.txt‘‘r‘);
CHBF1=fscanf(fid2‘%f‘);
fclose(fid2);

IHBF1in(1:LHBF1)=0;
QHBF1in(1:LHBF1)=0; % 进行半带滤波时的缓冲区

IHBF1out(1:2*Ns)=0;
QHBF1out(1:2:Ns)=0; % 两倍上采样后时域数据的存放数组
                    % I、Q分别表示I、Q两路信号

ii=1;
k=1;
k1=1;
k2=1;
k3=1;
k4=1;
k5=1;
t=1;
t2=1;
t3=1;

SoutI(1:Ns)=0;
SoutQ(1:Ns)=0; % 没有进行两倍上采样之前的时域数据存放数组
               % I、Q分别表示I、Q两路信号

IFFToutI(1:Symbol_num1:Nfft)=0;
IFFToutQ(1:Symbol_num1:Nfft)=0;
IFFToutIQ(1:Symbol_num1:Nfft)=0;
IFFToutIQS(1:Symbol_num1:Nfft)=0; % 进行IFFT运算后OFDM符号存放数组
                                   % I、Q分别表示I、Q两路信号
                                   % IQ表示复数信息

FFTout_t_1(1:Symbol_num1:2*Nfft)=0;
FFTout_t_2(1:Symbol_num1:4*Nfft)=0;
FFTout_t_3(1:Symbol_num1:8*Nfft)=0; % 测试变量




ii=1;

M_pilot=8;



subcarrier(1:N)=0;
subcarriercom(1:N)=0;

%train_word

% 获得短前导字频域信息
fid3=fopen(‘data_I_train_word_re_i0_256.txt‘‘r‘);
I_train_word_re_temp=fscanf(fid3‘%f‘)
fclose(fid3);
I_train_word_re = (I_train_word_re_temp)‘;

fid3=fopen(‘data_Q_train_word_re_i0_256.txt‘‘r‘);
Q_train_word_re_temp=fscanf(fid3‘%f‘)
fclose(fid3);
Q_train_word_re = (Q_train_word_re_temp)‘;

% 获得一个长前导字频域信息
fid3=fopen(‘data_I_train_word_1_i0_256.txt‘‘r‘);
I_train_word_1_temp=fscanf(fid3‘%f‘)
fclose(fid3);
I_train_word_1 = (I_train_word_1_temp)‘;

fid3=fopen(‘data_Q_train_word_1_i0_256.txt‘‘r‘);
Q_train_word_1_temp=fscanf(fid3‘%f‘)
fclose(fid3);
Q_train_word_1 = (Q_train_word_1_temp)‘;

% 获得二个长前导字频域信息
fid3=fopen(‘data_I_train_word_2_i0_256.txt‘‘r‘);
I_train_word_2_temp=fscanf(fid3‘%f‘)
fclose(fid3);
I_train_word_2 = (I_train_word_2_temp)‘;

fid3=fopen(‘data_Q_train_word_2_i0_256.txt‘‘r‘);
Q_train_word_2_temp=fscanf(fid3‘%f‘)
fclose(fid3);
Q_train_word_2 = (Q_train_word_2_temp)‘;

l=1;

%%%%%%%%%%%%%%^^^^^^^^^^^^^^^^^^^
%window sequence
% 加窗处理的参数设置
wind=zeros(1(Nfft+Ng));
windo=hamming(Nfft+Ng);
wind((Ng+1):Nfft)=windo((Ng+1):Nfft);
wind(1:Ng)=windo(Ng+1);
wind((Nfft+1):(Nfft+Ng))=windo(Nfft);

%%%%%%%%%%%%%%%%^^^^^^^^^^^^^^^^^^^




stst=1;

%%%%%%%%%%%%%%%$$$$$$$$$$$$$$$$$
% 获得随机数,当作用户信息,调制到各个子载波上
fid3=fopen(‘I1.txt‘‘r‘);
I1=fscanf(fid3‘%d‘);
fclose(fi

评论

共有 条评论