% 对OFDM系统进行建模,采用16QAM星座映射
clc;
clear all;
close all;
%============= OFDM系统参数设置================
carrier_count=200;
symbols_per_carrier=12;
bits_per_symbol=4;
IFFT_bin_length=512;
PrefixRatio=1/4;
GI=PrefixRatio*IFFT_bin_length; % 保护前缀长度
beta=1/16; %滚降系数
GIP=beta*(IFFT_bin_length+GI); %加窗扩展时域信号长度
SNR=0:30;
for m=1:length(SNR)
%=============发送端=======================
%=============信号产生=====================
baseband_out_length=carrier_count*symbols_per_carrier*bits_per_symbol;
%%进行子载波共轭映射,使得OFDM符号经过IFFT之后是实信号
carriers=(1:carrier_count)+(floor(IFFT_bin_length/4)-floor(carrier_count/2));
conjugate_carriers=IFFT_bin_length-carriers+2;
% rand('twister',0);
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)';
%================IFFT==================
IFFT_modulation=zeros(symbols_per_carrier,IFFT_bin_length);
IFFT_modulation(:,carriers)=complex_carrier_matrix;
IFFT_modulation(:,conjugate_carriers)=conj(complex_carrier_matrix);
%=================未添加保护间隔的OFDM符号===================================
signal_after_IFFT=ifft(IFFT_modulation,IFFT_bin_length,2);
time_wave_matrix=signal_after_IFFT;
%================添加循环前缀与后缀==================
XX=zeros(symbols_per_carrier,IFFT_bin_length+GI+GIP);
for k=1:symbols_per_carrier
for i=1:IFFT_bin_length
XX(k,i+GI)=signal_after_IFFT(k,i);
end
for i=1:GI
XX(k,i)=signal_after_IFFT(k,i+IFFT_bin_length-GI);
end
for j=1:GIP
XX(k,IFFT_bin_length+GI+j)=signal_after_IFFT(k,j);
end
end
time_wave_matrix_cp=XX;
%==============OFDM符号加窗=================================================
windowed_time_wave_matrix_cp=zeros(1,IFFT_bin_length+GI+GIP);
for i = 1:symbols_per_carrier
windowed_time_wave_matrix_cp(i,:)=real(time_wave_matrix_cp(i,:)).*rcoswindow(beta,IFFT_bin_length+GI)';
end
%========================生成发送信号,并串变换====================================
%这样做的目的在于将加窗的OFDM符号经过并串转换之后时,对于循环前缀是每个子信道都需要添加
%但是对于循环后缀不需要每个子信道都添加,因此串并之后只需要对整个串行符号添加就行
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,:);
for i = 1:symbols_per_carrier-1 ;
windowed_Tx_data((IFFT_bin_length+GI)*i+1:(IFFT_bin_length+GI)*(i+1)+GIP)=windowed_time_wave_matrix_cp(i+1,:);
end
%================================================================================
Tx_data_withoutwindow =reshape(time_wave_matrix_cp',(symbols_per_carrier)*(IFFT_bin_length+GI+GIP),1)';%未添加窗信号
Tx_data =reshape(windowed_time_wave_matrix_cp',(symbols_per_carrier)*(IFFT_bin_length+GI+GIP),1)';%加窗发送信号
%===============================================================================
temp_time1 = (symbols_per_carrier)*(IFFT_bin_length+GI+GIP);
temp_time2 =symbols_per_carrier*(IFFT_bin_length+GI)+GIP;
%=================未加窗发送信号频谱===============================================
symbols_per_average = ceil(symbols_per_carrier/5);
avg_temp_time = (IFFT_bin_length+GI+GIP)*symbols_per_average;
averages = floor(temp_time1/avg_temp_time);
average_fft(1:avg_temp_time) = 0;
for a = 0:(averages-1)
subset_ofdm = Tx_data_withoutwindow (((a*avg_temp_time)+1):((a+1)*avg_temp_time));
subset_ofdm_f = abs(fft(subset_ofdm));
average_fft = average_fft + (subset_ofdm_f/averages);
end
average_fft_log = 20*log10(average_fft);
%===============加窗的发送信号频谱=================================================
% symbols_per_average = ceil(symbols_per_carrier/5);
% avg_temp_time = (IFFT_bin_length+GI+GIP)*symbols_per_average;
% averages = floor(temp_time1/avg_temp_time);
% average_fft(1:avg_temp_time) = 0;
% for a = 0:(averages-1)
% subset_ofdm = Tx_data(((a*avg_temp_time)+1):((a+1)*avg_temp_time));
% subset_ofdm_f = abs(fft(subset_ofdm));
% average_fft = average_fft + (subset_ofdm_f/averages);
% end
% average_fft_log = 20*log10(average_fft);
%===============添加噪声(AWGN信道)==================
Tx_signal_power=var(windowed_Tx_data);
linear_SNR=10^(SNR(m)/10);
noise_sigma=Tx_signal_power/linear_SNR;
noise_scale_factor=sqrt(noise_sigma);
noise=randn(1,((symbols_per_carrier)*(IFFT_bin_length+GI)+GIP))*noise_scale_factor;
Rx_data=windowed_Tx_data+noise;
%==============接收端进行串并转换 去除循环前缀和后缀(对加窗信号进行处理)===========
Rx_data_matrix=zeros(symbols_per_carrier,IFFT_bin_length+GI+GIP);
for i=1:symbols_per_carrier
Rx_data_matrix(i,:)=Rx_data(1,(i-1)*(IFFT_bin_length+GI)+1:i*(IFFT_bin_length+GI)+GIP);
end
Rx_data_complex_matrix=Rx_data_matrix(:,GI+1:IFFT_bin_length+GI);
%===============================================================================
%====================OFDM解调, 16QAM解星座映射==================================
Y1=fft(Rx_data_complex_matrix,IFFT_bin_length,2);
Rx_carriers=Y1(:,carriers);
Rx_mag=abs(Rx_carriers);
Rx_phase=angle(Rx_carriers);
%============================================================================
[M, N]=pol2cart(Rx_phase, Rx_mag);
Rx_complex_carrier_matrix = complex(M, N);
%=============16QAM解调========================================================
Rx_serial_complex_symbols = reshape(Rx_complex_carrier_matrix',size(Rx_complex_carrier_matrix, 1)*size(Rx_complex_carrier_matrix,2),1)' ;
Rx_decoded_binary_symbols=demoduqam16(Rx_serial_complex_symbols);
%================================================================================
baseband_in = Rx_decoded_binary_symbols;
%================误码率计算=======================================================
bit_errors=find(baseband_in ~=baseband_out);
bit_error_count = size(bit_errors, 2);
ber(m)=bit_error_count/baseband_out_length;
end
figure;
semilogy(SNR,ber,'r-^','linewidth',1.5);
xlabel('SNR(dB)');
ylabel('BER');
title('the BER performance of the OFDM system(16QAM)');
grid on
hold on
邓凌佳
- 粉丝: 82
- 资源: 1万+
最新资源
- 上海牛津英语_高中一年级上_词汇提炼.doc
- 数学源于生活用于生活.doc
- 苏教版四年级(下册)按课文填空.doc
- 苏版四年级(上册)数学第四单元教学案.doc
- 我国农业银行笔试题目和答案.doc
- 网络安全知识试题库完整.doc
- 我国农业机械化的现状和发展趋势.doc
- 五年级解方程及应用题知识点及例题.doc
- 系学生会学习部申请书(精选多篇).doc
- 小学生科技活动辅导教学案.doc
- 小学数学课堂教学中小组合作学习的有效性.doc
- weixin411医疗就诊微信小程序设计与实现开发-0d26l+django .zip
- 学校团委书记竞聘演讲稿[精选多篇].doc
- 学校消防工作计划(精选多篇).doc
- 一级锅炉水处理试题和答案.doc
- 义务教育阶段双语教育新教双语教学质量评估自查自评报告.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈