%%*************************************************************************
%%此程序用来仿真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 ;
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
OFDM_channel_simulation.rar (14个子文件)
信道仿真
devi.m 99B
ClarkeModel.m 4KB
qpsk_awgn.m 7KB
channel.m 1KB
PDFTEST.m 761B
qpsk.m 856B
circonv.m 311B
modulation.m 6KB
Gngauss.m 802B
Qfunct.m 87B
f2t.M 137B
ofdm_awgn_ray_union.m 7KB
t2f.M 134B
demodulation.m 6KB
共 14 条
- 1
资源评论
钱亚锋
- 粉丝: 101
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 10、安徽省大学生学科和技能竞赛A、B类项目列表(2019年版).xlsx
- 9、教育主管部门公布学科竞赛(2015版)-方喻飞
- C语言-leetcode题解之83-remove-duplicates-from-sorted-list.c
- C语言-leetcode题解之79-word-search.c
- C语言-leetcode题解之78-subsets.c
- C语言-leetcode题解之75-sort-colors.c
- C语言-leetcode题解之74-search-a-2d-matrix.c
- C语言-leetcode题解之73-set-matrix-zeroes.c
- 树莓派物联网智能家居基础教程
- YOLOv5深度学习目标检测基础教程
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功