⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gofdmawgnsimple.m

📁 a simple implementation for 4 16 64 QAM plots to obtain simulated and theoretical results for OFDM s
💻 M
字号:
%  Title       :  OFDM over AWGN Channel
%              :  
%  Author      : goutam.ramamurthy.06<AT>student.lth.se
%  History     : 2008-12-18      created
%  References  :
%  Needs       : 
%  Description :
%
%        1         2         3         4         5         6         7         
%23456789012345678901234567890123456789012345678901234567890123456789012345
%
%
close all;
clear all;
clc;

%%%%%%%%%% SIMULATION PARAMETERS 
%coh_diff_flag = 1;      % 1->coherent ; 0->Differential

%%%%%%%%%% SYSTEM PARAMETERS 
%--General Parameters
BW_LTE = 20e6;          % Total Available LTE S/M bandwidth is 20 MHz
BW_guard = BW_LTE/10;   % 10% of Total available BW for OOB emissions 
M_ary = 4;              % order of modulation 
%--OFDM Specific design Parameters
delta_f = 15e3;         % LTE Sub-Carrier Spacing; specified by 3GPP
                        % also delta_f_low = 7.5e3 for MBMS
T_u = 1/delta_f;        % Actual LTE Symbol Duration => with no CP

T_cp = 5.2e-006;        % Guard band duration; time-domain
N_c = floor((BW_LTE - BW_guard)/delta_f);   % 1200 for 20MHz BW
m = ceil(log2(N_c));    % radix value for N=2^m in N-IFFT
N_FFT = 2^m;            % N_FFT > N_c & for radix-2 IFFT, S.T. N_FFT is 2^m
f_s = N_FFT * delta_f;  % fulfil the sampling theorem
T_s = 1/f_s;            % The sampling time
L_CP = floor(T_cp * f_s); % 

%~~~~~~~~~~~~~~
tic;
%%%%%%%%%% RANDOM SOURCE
%--Generate a column of random binary bits
N_bits = N_c * log2(M_ary);  %# of infobits, OFDM-equal loading on all syms
x_txbits = (1-sign(randn(N_bits,1)))/2; %(almost a) Bernoulli source(p=1/2)
%%%RANDOM SOURCE-ED

%%%%%%%%%% QAM MAPPER
%--using matlab's modem object
qam_mod = modem.qammod(M_ary);  % create a modulator object
qam_mod.symbolorder = 'gray' ;  % Enable gray coding
qam_mod.inputtype = 'bit';
qam_mod.disp;                   % Print the properties of modulator
qam_txsyms = modulate(qam_mod, x_txbits);  % QAM modulate
%%% QAM MAPPER -ED

%%%%%%%%%% OFDM modulator
N_txsyms = length(qam_txsyms); % estimate actual info bits and reqd zeros
txsyms_ext = zeros(N_FFT, 1);    % pad zeros to unused FFT bins
txsyms_ext(1:N_txsyms/2) = qam_txsyms(1:N_txsyms/2).'; %attach 2 halves to 2 ends of the N-pt OFDM sym
txsyms_ext((N_FFT-((N_txsyms/2)-1)):N_FFT) = qam_txsyms(((N_txsyms/2)+1):N_txsyms).';
ofdm_carr = N_FFT.*ifft(txsyms_ext, N_FFT);
%%%OFDM modulator -ED 

%%%%%%%%%% ADD CP
ofdm_carr_CP = [];  % add Cyclic Prefix
ofdm_carr_CP = [ofdm_carr_CP; ofdm_carr(N_FFT-L_CP+1:end); ofdm_carr];
%%%ADD CP -ED 

%++++++++++
%%%%%%%%%% THE CHANNEL TO CONVOLVE
rx_data = ofdm_carr_CP;
%%%CHANNEL CONVOLUT -ED 
%++++++++++

%%%%%%%%%% OFDM demodulator
N_rxsyms = N_txsyms;
rx_fft_2N = (1/N_FFT)*fft(rx_data(L_CP+1:N_FFT+L_CP), N_FFT); 
rx_syms = [];
rx_syms = [rx_syms; rx_fft_2N(1:N_rxsyms/2); rx_fft_2N((N_FFT-(N_rxsyms/2)+1):N_FFT)];
%%%%%%%%%%OFDM demodulator -ED 
 

%%%%%%%%%% QAM DEMAPPER
%--using matlab's modem object
qam_demod = modem.qamdemod(qam_mod);  % copy props from mod object
qam_demod.disp;                   % Print the properties of DE-modulator
x_rxbits = demodulate(qam_demod, rx_syms);  % QAM modulate
%%%QAM DEMAPPER -ED 

toc;

%%%%%%%%%% BER & PLOTS
%-- Bit Error Rate Curves
N_biterrs = nnz(x_rxbits(:)-x_txbits(:)); % no. of non-zero elems in diff.
%semilogy(SNRs_inDB, N_biterrs, 'b');

%-- Scatter plots
scatterplot(rx_syms);
title('TX QAM MOD SYMS');

%%%BER & PLOTS -ED

 
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -