%%*************************************************************************
%%此程序用来仿真OFDM系统在AWGN信道中的误码特性
%%Function information:
%%
%%-------------------------------------------------------------------------
%% Created by Wei Zhao 2003-04-17 (Version 1.0)
%%-------------------------------------------------------------------------
%% Recreated by Kunji Wang
%%*************************************************************************
%%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%% MAIN PROGRAM
%%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clear;
clc;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% System Parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NumOfSubcarrier = 64;
LengthOfGI = 16; % the subcarriers GI(guard interval)contains
modulation_mode = 4;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Simulation Parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NumOfSymbolPerFrame=5;
NumOfFrames=100;
SNR_in_dB=[0:4:30];
fs=10000;
fd=100;
Rb=fs;
Ts=1/Rb;
dt=Ts;
n_delay=3;
t_delay=[0,100,200];
p_delay=[0.0,-2.0,-6.0];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Simulation Starting!!!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tic;
for counter=1:length(SNR_in_dB)
P=1; % energy per symbol
snr=10^(SNR_in_dB(counter)/10); % signal to noise ratio
sgma=sqrt(P/(snr)); % noise variance
%Clear the all the counters
NumOfErrorBit = 0;
SampleIndex=0;
for Frame_counter = 1:NumOfFrames
%--------------------------------------------------------------------------------------------
% Tx
%--------------------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Source Bit Sequence
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Source_Bits=randint(1,2*NumOfSubcarrier*NumOfSymbolPerFrame);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% QPSK Modulation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Modulated_Sequence=modulation(Source_Bits,modulation_mode);
R_Modulated_Sequence=reshape(Modulated_Sequence,NumOfSubcarrier,NumOfSymbolPerFrame);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% IFFT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
IFFT_Out_Data(:,:) =sqrt(NumOfSubcarrier)* ifft (R_Modulated_Sequence);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% adding guard interval for DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GI_Added_Frame(1:LengthOfGI,:) = IFFT_Out_Data((NumOfSubcarrier-LengthOfGI+1):NumOfSubcarrier,:);
GI_Added_Frame((LengthOfGI+1):(NumOfSubcarrier+LengthOfGI),:) = IFFT_Out_Data(1:NumOfSubcarrier,:);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% P -> S
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Serial_Signal = reshape(GI_Added_Frame,1,NumOfSymbolPerFrame*(NumOfSubcarrier+LengthOfGI));
%%%------------------------------------------------------------------------------------------------------------
%% CHANNEL
%%%------------------------------------------------------------------------------------------------------------
%--------------------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% AWGN channel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
in=Serial_Signal;
[out]=channel(in,fs,fd,n_delay,t_delay,p_delay);
Serial_Signal_Ray=Serial_Signal*out;
for i=1:NumOfSymbolPerFrame*(NumOfSubcarrier+LengthOfGI)
[n_I n_Q]=gngauss(sgma);
noise(i)=n_I+j*n_Q;
end
Noised_Transmited_Signal=Serial_Signal_Ray+noise(i);
%--------------------------------------------------------------------------------------------
% Rx
%--------------------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Remove the GI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for jj=1:NumOfSymbolPerFrame
for ii=1:NumOfSubcarrier
GI_Removed_Rx_Signal(ii+(jj-1)*NumOfSubcarrier)=Noised_Transmited_Signal(LengthOfGI*jj+ii+(jj-1)*NumOfSubcarrier);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% S -> P
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Parallel_Rx_Signal = reshape(GI_Removed_Rx_Signal,NumOfSubcarrier,NumOfSymbolPerFrame);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% FFT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Freq_Rx_Signal = fft(Parallel_Rx_Signal)/sqrt(NumOfSubcarrier);
Demod_In_Data(1:NumOfSubcarrier,1:NumOfSymbolPerFrame) = Freq_Rx_Signal(1:NumOfSubcarrier,1:NumOfSymbolPerFrame);
FFT_Out = conj(Demod_In_Data(:,1:NumOfSymbolPerFrame)');
Serial_Output = reshape(Demod_In_Data,1,NumOfSubcarrier*NumOfSymbolPerFrame);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Demodulation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Demod_Sequence= demodulation(Serial_Output,modulation_mode);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Calculate the BER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for jj = 1:(length(Source_Bits))
if Demod_Sequence(jj) ~= Source_Bits(jj)
NumOfErrorBit = NumOfErrorBit + 1;
end
end
end
BER(counter) = NumOfErrorBit/(NumOfFrames*NumOfSubcarrier*2*NumOfSymbolPerFrame);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Simulation Completed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elapse=toc
clock_time = clock;
present = fix(clock_time)
%---------------------------------------------%
%% Draw BER figure
%---------------------------------------------%
h=figure;
semilogy(SNR_in_dB,BER,'r*-');
xlabel('SNR(dB)');
ylabel('BER(bit error rate)');
title( 'BER performance of OFDM in AWGN Channel');
grid on ;
钱亚锋
- 粉丝: 106
- 资源: 1万+
最新资源
- MBR污水一体化处理系统(集装箱)工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- lattice diamond3.11的license文件
- vsvbxcygsyzgvytfvdyvs
- DJS-042-锁螺丝机方案工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- FMASTERSW3.2版本
- qemu上运行Linux系统开启并验证IMA功能
- HE-Drive-main.zip
- mysql安装配置教程.txt
- mysql安装配置教程.txt
- mysql安装配置教程.txt
- 汇川伺服6V30-EOE-MXL文件-037515
- 2024中国CIO&CDO现状、挑战及未来趋势研究报告
- 鼠标连点器+自动单机+录制点击
- 4G DTU串口数据采集网关设计全套资料(源码、原理图、外壳文件、产品手册).zip
- 利用Python绘制装饰圣诞树的技术实例
- 测试程序:qabstractvideosurface
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈