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

📄 dvb_t_platform.m

📁 通过图形实现OFMD的图像仿真
💻 M
字号:
% ofdm_dvbt2k.m
%
% DVB-T 2K OFDM transmission system
% No pilot; AWGN channel only
%
% Programmed by Tang Shigang
%

%************** Preparation part ********************
clear all; clc;
para = 1705;                 % Number of parallel channels to transmit
fftlen = 2048;               % FFT length
ml = 4;                      % Modulation level : QAM
nd = 1;                      % Number of OFDM symbols for one simulation loop
Tu = 224e-6;                 % Symbol period
T = Tu/fftlen;
% sr = 1e6;                    % Symbol rate
% br = sr.*ml;                 % Bit rate per carrier
gi = 1/8;                    % Guard interval, choosing from 1/4,1/8,1/16 and 1/32 
gilen = gi*fftlen;           % Length of guard interval (points)
delta = gi*Tu;               % Guard Interval duration
Ts = delta + Tu;             % Total OFDM symbol period
%ppow = 16/9;                 % Pilot power, 2.5dB larger than the power of data
                             % Pilot insertion method : uniform continuous
                             % pilot, K = Kmin+12p,p>=0,p integer,Kmin<=K<=Kmax
%plen = 143;                  % Pilot length (dots)

nloop = 1;                   % Number of simulation loops. If you want simulate the BER vs. SNR plot,
                             % please enlarge the nloop value. For instance, nloop = 10000.
noe = 0;                     % Number of error data
nod = 0;                     % Number of transmitted data

for iii = 1:nloop

%************* Transmitter **************************

% Data generation
seridata = randint(1,para*nd*ml,2);

% Serial to parallel conversion
paradata = reshape(seridata,para,nd*ml);

% QPSK modulation
[ich,qch] = qpskmod(paradata,para,nd,ml);
kmod = 1/sqrt(2);
ich = ich.*kmod;
qch = qch.*kmod;

% Constellations plot in transmitter
% please make your own codes

% Pilot insertion
% If you want to insert pilot, please change the following codes
ich1 = ich;
qch1 = qch;

% Zero padding (subcarrier allocation), DC=0
ich2 = zeros(fftlen,nd);
qch2 = zeros(fftlen,nd);
ich2(2:854,:) = ich1(1:853,:);
qch2(2:854,:) = qch1(1:853,:);
ich2(1197:2048,:) = ich1(854:1705,:);
qch2(1197:2048,:) = qch1(854:1705,:);

% IFFT
x = ich2+qch2*i;
y = ifft(x);
ich3 = real(y);
qch3 = imag(y);

% Guard interval insertion
ich4 = [ ich3(fftlen-gilen+1:fftlen,:); ich3 ];
qch4 = [ qch3(fftlen-gilen+1:fftlen,:); qch3 ];
ich4g = reshape(ich4,1,(fftlen+gilen)*nd);
qch4g = reshape(qch4,1,(fftlen+gilen)*nd);
fftlen2 = fftlen + gilen;

% Spectrum scoope
% To plot the spectrum of the transmitted signal, please make your own
% codes
t=0:(fftlen2-1);
time=ich4g+i*qch4g;
amp_time=abs(time);
ang_time=angle(time);
figure;          %plot the signal in time domain
subplot(2,1,1);
plot(Tu*t,amp_time);
subplot(2,1,2);
plot(Tu*t,ang_time);
frequency=fftshift(fft(time));    %transform the signal to frequency domain
amp_frequency=abs(frequency);
ang_frequency=angle(frequency);
figure;                          %plot the signal in frequency domain
subplot(2,1,1);
plot(2*pi*t/2304,amp_frequency);
subplot(2,1,2);
plot(2*pi*t/2304,ang_frequency);
% 
% %******************  Receiver  **************************
% 
% AWGN addition
%attn = 0.01;
%ich5 = ich4g + randn(1,length(ich4g)).*attn;
%qch5 = qch4g + randn(1,length(qch4g)).*attn;
snr = 8;
ndata = awgn(ich4g+i*qch4g,snr,'measured');
ich5 = real(ndata);
qch5 = imag(ndata);

% Guard interval removal
idata2 = reshape(ich5,fftlen2,nd);
qdata2 = reshape(qch5,fftlen2,nd);
ich6 = idata2(gilen+1:fftlen2,:);
qch6 = qdata2(gilen+1:fftlen2,:);

% FFT
rx = ich6 + qch6*i;
ry = fft(rx);
ich7 = real(ry);
qch7 = imag(ry);

% Subcarrier selection
ich8(1:853,:) = ich7(2:854,:);
qch8(1:853,:) = qch7(2:854,:);
ich8(854:1705,:) = ich7(1197:2048,:);
qch8(854:1705,:) = qch7(1197:2048,:);

%Demodulate data
ich9 = ich8./kmod;
qch9 = qch8./kmod;
demodata1 = qpskdemod(ich9,qch9,para,nd,ml);

% Constellations plot
% to plot the constellations in the receiver, please make your own codes
%comdata1 = ich1 + i*qch1;              % Complex modulated data
%comdata2 = ich7 + i*qch7;
scatterplot(x)                  % Plotting signal constellations
title('Constellation before AWGN')
axis([-3 3 -3 3])
scatterplot(ry)                  
title('Constellation after AWGN')
axis([-3 3 -3 3])
% Error calculation
demodata = reshape(demodata1,1,para*nd*ml);
noe2 = sum(abs(demodata-seridata));
nod2 = length(seridata);

noe = noe + noe2;
nod = nod + nod2;

end

ber = noe/nod; 







⌨️ 快捷键说明

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