✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
个人主页:Matlab科研工作室
个人信条:格物致知。
更多Matlab仿真内容点击
智能优化算法 神经网络预测 雷达通信 无线传感器
信号处理 图像处理 路径规划 元胞自动机 无人机 电力系统
SIMULINK是MATLAB中动态系统建模、仿真和分析的一个集成环境,文中按照仿真过程基本步骤用MATLAB的仿真工具SIMUINK实现了数字信号基带传输系统的仿真过程,对系统性能进行了分析.
% PILOT BASED CHANNEL ESTIMATION (FFT BASED) FOR OFDM SYSTEMS
close all
clear all
clc
SNR_dB = 40;% SNR PER BIT
NUM_FRAMES = 10^2;
FFT_LEN = 1024;
NUM_PILOT = 256;
NUM_BIT = 2*(FFT_LEN-NUM_PILOT); % NUMBER OF DATA BITS
CHAN_LEN = 10; % NUMBER OF CHANNEL TAPS
CP_LEN = CHAN_LEN-1; % LENGTH OF THE CYCLIC PREFIX
FADE_VAR_1D = 0.5; % 1D FADE VARIANCE OF THE CHANNEL
FADE_STD_DEV = sqrt(FADE_VAR_1D); % STANDARD DEVIATION OF THE FADING CHANNEL
% SNR PER BIT PARAMETERS - OVERALL RATE IS 2
SNR = 10^(0.1*SNR_dB); % LINEAR SCALE
NOISE_VAR_1D = 0.5*2*2*CHAN_LEN*FADE_VAR_1D/(2*SNR*FFT_LEN); % 1D AWGN NOISE VARIANCE
NOISE_STD_DEV = sqrt(NOISE_VAR_1D); % NOISE STANDARD DEVIATION
% PILOT AND DATA INDICES IN OFDM FRAME
PILOT_INDEX = 1:FFT_LEN/NUM_PILOT:FFT_LEN; % PILOT POSITION INDICES
DATA_INDEX = 1:FFT_LEN;
DATA_INDEX(PILOT_INDEX) = []; % DATA POSITION INDICES
tic()
C_BER = 0; % bit errors in each frame
for FRAME_CNT = 1:NUM_FRAMES
%---- TRANSMITTER -----------------------------------------
% SOURCE
A = randi([0 1],1,NUM_BIT);
% QPSK MAPPING
QPSK_SEQ = 1-2*A(1:2:end) + 1i*(1-2*A(2:2:end));
F_SIG_NO_CP = zeros(1,FFT_LEN); % F STANDS FOR FREQUENCY DOMAIN
F_SIG_NO_CP(DATA_INDEX) = QPSK_SEQ;
F_SIG_NO_CP(PILOT_INDEX) = (1+1i)*ones(1,NUM_PILOT);
% IFFT
T_SIG_NO_CP = ifft(F_SIG_NO_CP);
% INSERTING CYCLIC PREFIX
T_SIG_CP = [T_SIG_NO_CP(end-CP_LEN+1:end) T_SIG_NO_CP];
%--------------- CHANNEL -----------------------------------------
% RAYLEIGH FREQUENCY SELECTIVE FADING CHANNEL
FADE_CHAN = normrnd(0,FADE_STD_DEV,1,CHAN_LEN)+1i*normrnd(0,FADE_STD_DEV,1,CHAN_LEN);
% FADE CHANNEL OUTPUT
CHAN_OP_TEMP = conv(T_SIG_CP,FADE_CHAN);
% AWGN
AWGN = normrnd(0,NOISE_STD_DEV,1,FFT_LEN+CP_LEN+CHAN_LEN-1)+1i*normrnd(0,NOISE_STD_DEV,1,FFT_LEN+CP_LEN+CHAN_LEN-1);
% AWGN OUTPUT
T_REC_SIG = CHAN_OP_TEMP + AWGN;
%---------------- RECEIVER ------------------------------------------
% CP & TRANSIENT SAMPLES REMOVAL
T_REC_SIG(1:CP_LEN) = [];
T_REC_SIG_NO_CP = T_REC_SIG(1:FFT_LEN);
% PERFORMING THE FFT
F_REC_SIG_NO_CP = fft(T_REC_SIG_NO_CP);
%--------------------------------------------------------------------------
% FFT BASED CHANNEL ESTIMATION
E_F_PILOT_POS = F_REC_SIG_NO_CP(PILOT_INDEX)./(1+1i); % 1-TAP EQUALIZATION
E_T_PILOT_POS = ifft(E_F_PILOT_POS); % L_p point IFFT
% DISCARDING SAMPLES AFTER LOCATION CHAN_LEN
E_H_CHAN_LEN = E_T_PILOT_POS(1:CHAN_LEN);
% ZERO PADDING AND TAKING ITS IIT
E_F_H = fft(E_H_CHAN_LEN,FFT_LEN); % zero padding and FFT_LEN point FFT
% CHANNEL SUBCARRIERS AT DATA POSITIONS
E_F_H_DATA_POS = E_F_H(DATA_INDEX);
%--------------------------------------------------------------------------
% ML DETECTION
QPSK_SYM = [1+1i 1-1i -1+1i -1-1i];
QPSK_SYM1 = QPSK_SYM(1)*ones(1,FFT_LEN-NUM_PILOT);
QPSK_SYM2 = QPSK_SYM(2)*ones(1,FFT_LEN-NUM_PILOT);
QPSK_SYM3 = QPSK_SYM(3)*ones(1,FFT_LEN-NUM_PILOT);
QPSK_SYM4 = QPSK_SYM(4)*ones(1,FFT_LEN-NUM_PILOT);
DIST = zeros(4,FFT_LEN-NUM_PILOT);
DIST(1,:)=(abs(F_REC_SIG_NO_CP(DATA_INDEX) - E_F_H_DATA_POS.*QPSK_SYM1)).^2;
DIST(2,:)=(abs(F_REC_SIG_NO_CP(DATA_INDEX) - E_F_H_DATA_POS.*QPSK_SYM2)).^2;
DIST(3,:)=(abs(F_REC_SIG_NO_CP(DATA_INDEX) - E_F_H_DATA_POS.*QPSK_SYM3)).^2;
DIST(4,:)=(abs(F_REC_SIG_NO_CP(DATA_INDEX) - E_F_H_DATA_POS.*QPSK_SYM4)).^2;
% COMPARING EUCLIDEAN DISTANCE
[~,INDICES] = min(DIST,[],1);
% MAPPING INDICES TO QPSK SYMBOLS
DEC_QPSK_MAP_SYM = QPSK_SYM(INDICES);
% DEMAPPING QPSK SYMBOLS TO BITS
DEC_A = zeros(1,NUM_BIT);
DEC_A(1:2:end) = real(DEC_QPSK_MAP_SYM)<0;
DEC_A(2:2:end) = imag(DEC_QPSK_MAP_SYM)<0;
% CALCULATING BIT ERRORS IN EACH FRAME
C_BER = C_BER + nnz(A-DEC_A);
end
toc()
BER = C_BER/(NUM_BIT*NUM_FRAMES)
[1]曲中水, 王建卫, 朱泳. 基于MATLAB的数字信号基带传输系统仿真[J]. 森林工程, 2004, 20(4):3.
❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料