OFDM数据源.md

按照LTE的格式产生一个slot的OFDM数据源,包含7个symbol;其中第一个symbol的CP为extendedCP(160Ts),其余6个symbol CP为normal CP(144Ts).

  • LTE20MHz子载波个数不超过1200
  • fft点数为N=2^x
  • CP 拷贝symbol的后n个Ts插入到symbol的前边
  • ifft变换之后的数据的能量是之前的数据能量的1/sqrt(N);需要乘以sqrt(N),保持前后数据能量相等

ifft公式
OFDM数据源.md_第1张图片
Paste_Image.png
OFDM数据源.md_第2张图片
OFDM生成步骤

OFDM参数选择N=64,CP=16,一个symbol的产生过程


OFDM数据源.md_第3张图片
Paste_Image.png

OFDM参数选择N=2^11,CP=160,一个symbol的产生过程


OFDM数据源.md_第4张图片
Paste_Image.png
OFDM数据源.md_第5张图片
频谱
%script for LTE OFDM 1-slot data src 

%% config parameter
clc,clear all;
N = 2^11;
%144/160;
normalCP = 144;
extendedCP = 160;
M = 1200; %num of subcarrier
modulation = 1;

%% generate symbol with normal CP
for t = 1:6
    if modulation==0
        data_src = rand(M,1)+1i*rand(M,1);
    else
        %qpsk
        data_src = randi([0,1],M,1)+1i*randi([0,1],M,1);
        for k=1:length(data_src)
            if(data_src(k)==1)
                data_src(k)=1/sqrt(2)-i/sqrt(2);
            elseif(data_src(k)==i)
                data_src(k)=-1/sqrt(2)+i/sqrt(2);
            elseif(data_src(k)==1+i)
                data_src(k)=1/sqrt(2)+i/sqrt(2);
            elseif(data_src(k)==0)
                data_src(k)=-1/sqrt(2)-i/sqrt(2);
            end
        end
    end
    data_src_pad0=[zeros((N-M)/2,1)',data_src',zeros((N-M)/2,1)']';
    data_src_pad0_shift = zeros(N,1);
    data_src_pad0_shift(1:N/2) = data_src_pad0(N/2+1:N);
    data_src_pad0_shift(N/2+1:N) = data_src_pad0(1:N/2);
    data_ifft = sqrt(N)*ifft(data_src_pad0_shift,N);
    data_ifft_pad_cp = zeros(N+normalCP,1);
    data_ifft_pad_cp(1:normalCP) = data_ifft(N-normalCP+1:N);
    data_ifft_pad_cp(normalCP+1:N+normalCP) = data_ifft;
    data_ifft_pad_cp6(:,t) = data_ifft_pad_cp;
end

%%  generate symbol with extended CP
figure(1)
if modulation==0
    data_src = rand(M,1)+1i*rand(M,1);
else
    data_src = randi([0,1],M,1)+1i*randi([0,1],M,1);
        for k=1:length(data_src)
            if(data_src(k)==1)
                data_src(k)=1/sqrt(2)-i/sqrt(2);
            elseif(data_src(k)==i)
                data_src(k)=-1/sqrt(2)+i/sqrt(2);
            elseif(data_src(k)==1+i)
                data_src(k)=1/sqrt(2)+i/sqrt(2);
            elseif(data_src(k)==0)
                data_src(k)=-1/sqrt(2)-i/sqrt(2);
            end
        end
end
subplot(5,1,1);
stem(1:length(data_src),abs(data_src));
title('input data')

data_src_pad0=[zeros((N-M)/2,1)',data_src',zeros((N-M)/2,1)']';
subplot(5,1,2);
stem(1:length(data_src_pad0),abs(data_src_pad0));
title('input data&Zero pad')

data_src_pad0_shift = zeros(N,1);
data_src_pad0_shift(1:N/2) = data_src_pad0(N/2+1:N);
data_src_pad0_shift(N/2+1:N) = data_src_pad0(1:N/2);
%data_src_pad0_shift=data_src_pad0;
subplot(5,1,3);
stem(1:length(data_src_pad0_shift),abs(data_src_pad0_shift));
title('input data&Zero pad shift')

data_ifft = sqrt(N).*ifft(data_src_pad0_shift,N);   %keep data rms() before/after ifft equalify
%data_ifft = ifft(data_src_pad0_shift,N);   %keep data rms() before/after ifft equalify
subplot(5,1,4);
stem(1:length(data_ifft),abs(data_ifft));
title('input data ifft')

data_ifft_pad_cp_e = zeros(N+extendedCP,1);
data_ifft_pad_cp_e(1:extendedCP) = data_ifft(N-extendedCP+1:N);
data_ifft_pad_cp_e(extendedCP+1:N+extendedCP) = data_ifft;
data_ifft_pad_cp_e = data_ifft_pad_cp_e;
subplot(5,1,5);
stem(1:length(data_ifft_pad_cp_e),abs(data_ifft_pad_cp_e));
title('input data ifft & CP')

%% combine to form 1slot data
data_ifft_1slot(1:length(data_ifft_pad_cp_e),1) = data_ifft_pad_cp_e;
for i=1:6
    data_ifft_1slot(length(data_ifft_pad_cp_e)+1+length(data_ifft_pad_cp)*(i-1):length(data_ifft_pad_cp_e)+length(data_ifft_pad_cp)*i,1) = data_ifft_pad_cp6(:,i);
end

figure(2)
df = abs(fftshift(fft(data_ifft_1slot)));
dfm=max(df);
dfl=20*log10(df/dfm);% spectrum magnitude

subplot(2,2,1)
grid on;
plot(1:length(df),df);
title('amplitude')
subplot(2,2,2)
plot(1:length(df),dfl);
title('normalize amplitude')
subplot(2,2,3)
dfp=10*log10(df.^2/dfm.^2);
plot(1:length(df),dfp);
title('normalize power')


你可能感兴趣的:(OFDM数据源.md)