www.pudn.com > ofdm_trans.rar > ofdm_trans.m


%DVB-T 2K Transmission 
%The available bandwidth is 8 MHz 
%2K is intended for mobile services 
clear all; 
close all; 
%--------------------------DVB-T Parameters--------------------------------------------------------- 
Tu=224e-6;                                                      %useful OFDM symbol period 
T=Tu/2048;                                                      %baseband elementary period 
G=0;                                                            %choice of 1/4, 1/8, 1/16, and 1/32 
delta=G*Tu;                                                     %guard band duration 
Ts=delta+Tu;                                                    %total OFDM symbol period 
Kmax=1705;                                                      %number of subcarriers 
Kmin=0; 
FS=4096;                                                        %IFFT/FFT length 
q=10;                                                           %carrier period to elementary period ratio 
fc=q*1/T;                                                       %carrier frequency 
Rs=4*fc;                                                        %simulation period 
t=0:1/Rs:Tu; 
%--------------------------Data generator (A)------------------------------------------------------- 
M=Kmax+1;                                                       %所有子载波的数目 
rand('state',0);                                                %确定随机变量种子    
a=-1+2*round(rand(M,1)).'+i*(-1+2*round(rand(M,1))).';          %生成信息位的复数据,实部与虚部变化范围为-1到1    
A=length(a);                                                    %信息位长度 
info=zeros(FS,1);                                               %信息位数据先赋零 
info(1:(A/2)) = [ a(1:(A/2)).'];                                %信息位从1到1706/2赋随机复数 
info((FS-((A/2)-1)):FS) = [ a(((A/2)+1):A).'];                  %信息位从4906-1706/2+1赋随机复数,中间部分全部赋零 
%----------------------------Subcarriers generation (B)------------------------------------------------- 
carriers=FS.*ifft(info,FS);                                     %对信息位作长度为4096的IFFT(OFDM调制) 
tt=0:T/2:Tu;                                                    %由于重采样信息位之间时间间隔有T变化为T/2 
figure(1); 
subplot(211); 
stem(tt(1:20),real(carriers(1:20)));                            %画出前20个调制数据的实部 
subplot(212); 
stem(tt(1:20),imag(carriers(1:20)));                            %画出前20个调制数据的虚部 
figure(2); 
f=(2/T)*(1:(FS))/(FS);                                          %给出调制数据的频率尺度f 
subplot(211); 
plot(f,abs(fft(carriers,FS))/FS);                               %画出调制数据的频域幅度谱 
subplot(212); 
pwelch(carriers,[],[],[],2/T);                                  %画出调制数据的功率谱密度 
% -------------------------------D/A simulation--------------------------------------------------------------- 
L = length(carriers);                                           %调制数据长度 
chips = [ carriers.';zeros((2*q)-1,L)];                         %以下七句模拟连续的调制数据(实际上就是将抽样率升至RS) 
p=1/Rs:1/Rs:T/2; 
g=ones(length(p),1);                                            %pulse shape 
figure(3); 
stem(p,g); 
dummy=conv(g,chips(:)); 
u=[dummy(1:length(t))];                                         % (C) 
figure(4); 
subplot(211); 
plot(t(1:400),real(u(1:400)));                                  %画出连续调制数据的前400点的实部 
subplot(212); 
plot(t(1:400),imag(u(1:400)));                                  %画出连续调制数据的前400点的虚部 
figure(5); 
ff=(Rs)*(1:(q*FS))/(q*FS);                                      %给出连续调制数据的频率尺度ff     
subplot(211); 
plot(ff,abs(fft(u,q*FS))/FS);                                   %给出连续调制数据的频域幅度谱 
subplot(212); 
pwelch(u,[],[],[],Rs);                                          %画出连续调制数据的功率谱密度 
[b,a] = butter(13,1/20);                                        %reconstruction filter 
[H,F] = FREQZ(b,a,FS,Rs);                                       %给出低通滤波器的频响特性 
figure(6); 
plot(F,20*log10(abs(H)));                                       %画出低通频响  
uoft = filter(b,a,u);                                           %连续数据过低通 
figure(7); 
subplot(211); 
plot(t(80:480),real(uoft(80:480)));                             %画出经过低通的数据的实部 
subplot(212); 
plot(t(80:480),imag(uoft(80:480)));                             %画出经过低通的数据的虚部 
figure(8); 
subplot(211); 
plot(ff,abs(fft(uoft,q*FS))/FS);                                %画出过D/A变换后的数据的频域幅度谱 
subplot(212); 
pwelch(uoft,[],[],[],Rs);                                       %画出过D/A变换后的数据的功率谱密度 
%-----------------------------------Upconverter--------------------------------------------------------- 
s_tilde=(uoft.').*exp(1i*2*pi*fc*t);                            %以fc为载波对经过D/A变换后的数据作上变频 
s=real(s_tilde);                                                %passband signal (E) 
figure(9); 
plot(t(80:480),s(80:480));                                      %画出经过上变频后的数据 
figure(10); 
subplot(211); 
%plot(ff,abs(fft(((real(uoft).').*cos(2*pi*fc*t)),q*FS))/FS);    
%plot(ff,abs(fft(((imag(uoft).').*sin(2*pi*fc*t)),q*FS))/FS); 
plot(ff,abs(fft(s,q*FS))/FS);                                   %画出经过上变频后的数据的频域幅度谱 
subplot(212); 
%pwelch(((real(uoft).').*cos(2*pi*fc*t)),[],[],[],Rs); 
%pwelch(((imag(uoft).').*sin(2*pi*fc*t)),[],[],[],Rs); 
pwelch(s,[],[],[],Rs);                                          %画出经过上变频后的数据的功率谱密度