ofdm主程序Word格式文档下载.docx
《ofdm主程序Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《ofdm主程序Word格式文档下载.docx(7页珍藏版)》请在冰豆网上搜索。
d3*d;
3*d3*d;
-3*dd;
-dd;
dd;
3*dd;
-3*d-d;
-d-d;
d-d;
3*d-d;
-3*d-3*d;
-d-3*d;
d-3*d;
3*d-3*d];
length(bitdata)/4
qam_data(i,:
)=mapping(source(i),:
);
%datamapping
complex_qam_data=complex(qam_data(:
1),qam_data(:
2));
5.216QAM的解调函数。
function[demodu_bit_symble]=demoduqam16(Rx_serial_complex_symbols)
%将得到的串行16QAM数据解调成二进制比特流
complex_symbols=reshape(Rx_serial_complex_symbols,length(Rx_serial_complex_symbols),1);
complex_mapping=complex(mapping(:
1),mapping(:
length(Rx_serial_complex_symbols);
16;
metrics(j)=abs(complex_symbols(i,1)-complex_mapping(j,1));
[min_metricdecode_symble(i)]=min(metrics);
%将离某星座点最近的值赋给
decode_symble(i)
decode_bit_symble=de2bi((decode_symble-1)'
'
left-msb'
demodu_bit_symble=reshape(decode_bit_symble'
1,length(Rx_serial_complex_symbols)*4);
5.3加窗函数
function[rcosw]=rcoswindow(beta,Ts)
%定义升余弦窗,其中beta为滚降系数,Ts为包含循环前缀的OFDM符号的长度,Ts为正偶
数
t=0:
(1+beta)*Ts;
rcosw=zeros(1,(1+beta)*Ts);
beta*Ts;
rcosw(i)=0.5+0.5*cos(pi+t(i)*pi/(beta*Ts));
rcosw(beta*Ts+1:
Ts)=1;
forj=Ts+1:
(1+beta)*Ts+1;
rcosw(j-1)=0.5+0.5*cos((t(j)-Ts)*pi/(beta*Ts));
rcosw=rcosw'
%变换为列向量
5.4OFDM主程序
clearall;
closeall;
carrier_count=200;
%子载波数
symbols_per_carrier=12;
%每子载波含符号数
bits_per_symbol=4;
%每符号含比特数,16QAM调制
IFFT_bin_length=512;
%FFT点数
PrefixRatio=1/4;
%保护间隔与OFDM数据的比例1/6~1/4
GI=PrefixRatio*IFFT_bin_length;
%每一个OFDM符号添加的循环前缀长度为
1/4*IFFT_bin_length即保护间隔长度为128
beta=1/32;
%窗函数滚降系数
GIP=beta*(IFFT_bin_length+GI);
%循环后缀的长度20
SNR=15;
%信噪比dB
%==================================================
%================信号产生===================================
baseband_out_length=carrier_count*symbols_per_carrier*bits_per_symbol;
%所输入的比特
数目
carriers=(1:
carrier_count)+(floor(IFFT_bin_length/4)-floor(carrier_count/2));
%共轭对称子载
波映射复数数据对应的IFFT点坐标
conjugate_carriers=IFFT_bin_length-carriers+2;
%共轭对称子载波映射共轭复数对应的
IFFT点坐标
baseband_out=round(rand(1,baseband_out_length));
%输出待调制的二进制比特流
%==============16QAM调制====================================
complex_carrier_matrix=qam16(baseband_out);
%列向量
complex_carrier_matrix=reshape(complex_carrier_matrix'
carrier_count,symbols_per_carrier)'
%s
ymbols_per_carrier*carrier_count矩阵
figure
(1);
plot(complex_carrier_matrix,'
*r'
%16QAM调制后星座图
title('
16QAM调制后星座图'
)
axis([-4,4,-4,4]);
gridon
%=================IFFT===========================
IFFT_modulation=zeros(symbols_per_carrier,IFFT_bin_length);
%添0组成IFFT_bin_length
IFFT运算
IFFT_modulation(:
carriers)=complex_carrier_matrix;
%未添加导频信号,子载波映射在此
处
conjugate_carriers)=conj(complex_carrier_matrix);
%共轭复数映射
%=================================================================
signal_after_IFFT=ifft(IFFT_modulation,IFFT_bin_length,2);
%OFDM调制即IFFT变换
time_wave_matrix=signal_after_IFFT;
%时域波形矩阵,行为每载波所含符号数,列ITTF点
数,N个子载波映射在其内,每一行即为一个OFDM符号
%===========================================================
%=====================添加循环前缀与后缀
====================================
XX=zeros(symbols_per_carrier,IFFT_bin_length+GI+GIP);
fork=1:
symbols_per_carrier;
IFFT_bin_length;
XX(k,i+GI)=signal_after_IFFT(k,i);
GI;
XX(k,i)=signal_after_IFFT(k,i+IFFT_bin_length-GI);
%添加循环前缀
GIP;
XX(k,IFFT_bin_length+GI+j)=signal_after_IFFT(k,j);
%添加循环后缀
time_wave_matrix_cp=XX;
%添加了循环前缀与后缀的时域信号矩阵,此时一个OFDM符号长
度为IFFT_bin_length+GI+GIP=660
%==============OFDM符号加窗==========================================
windowed_time_wave_matrix_cp=zeros(1,IFFT_bin_length+GI+GIP);
fori=1:
symbols_per_carrier
windowed_time_wave_matrix_cp(i,:
)=
real(time_wave_matrix_cp(i,:
)).*rcoswindow(beta,IFFT_bin_length+GI)'
%加窗升余弦窗
%========================生成发送信号,并串变换
==================================================
windowed_Tx_data=zeros(1,symbols_per_carrier*(IFFT_bin_length+GI)+GIP);
windowed_Tx_data(1:
IFFT_bin_length+GI+GIP)=windowed_time_wave_matrix_cp(1,:
symbols_per_carrier-1;
windowed_Tx_data((IFFT_bin_length+GI)*i+1:
(IFFT_bin_length+GI)*(i+1)+GIP)=windowed_ti
me_wave_matrix_cp(i+1,:
%并串转换,循环后缀与循环前缀相叠加
%=======================================================
Tx_data=reshape(windowed_time_wave_matrix_cp'
(symbols_per_carrier)*(IFFT_bin_length+GI
+GIP),1)'
%加窗后循环前缀与后缀不叠加的串行信号
temp_t