F-OFDM 系统简单Matlab搭建

1、源论文

  • 陈勇. 面向5G的F-OFDM关键技术研究[D].电子科技大学,2020.

本文相关参数均使用了论文中的参数,使用AWGN信道,但为了简单起见调制方式使用BPSK。

2、代码文件(Matlab R2019b)

  • 主文件
clc;
clear all;
%% 滤波器设计
M_1_object = M_1;
rrcFilterNum_M_1 = M_1_object.Numerator;
% wvtool(rrcFilterNum_M_1);
% fvtool(rrcFilterNum_M_1);
% pwelch(rrcFilterNum_M_1);
M_2_object = M_2;
rrcFilterNum_M_2 = M_2_object.Numerator;

M_3_object = M_3;
rrcFilterNum_M_3 = M_3_object.Numerator;
%% 参数设计
%fft窗口
N_fft_1 = 2048;
N_fft_2 = 1024;
N_fft_3 = 8192;
%子带部分数据
band_width = 720000;    %子带带宽(Hz)
Sc_spacing_1 = 15000;   %子载波间隔
Sc_spacing_2 = 30000;
Sc_spacing_3 = 3750;
%保护子载波数
N1 = 0;
N21 = 3;
N22 = 3;
N3 = 0;
%时隙符号数
N_symbol_1 = 7;
N_symbol_2 = 5;
N_symbol_3 = 3;
%时隙时间(ms)
Num_frame_3 = 1000;
Time_1 = 0.5/Num_frame_3; %672bit/1ms
Time_2 = 0.2/Num_frame_3; %600bit/1ms
Time_3 = 1/Num_frame_3; %576bit/1ms
%子载波映射编号
N_sc_1 = band_width/Sc_spacing_1;
N_sc_2 = band_width/Sc_spacing_2;
N_sc_3 = band_width/Sc_spacing_3;

M_2_min = 76;
M_2_max = 99;

M_1_min = (M_2_min - 1 - N21)*Sc_spacing_2/Sc_spacing_1 -N1 -N_sc_1 +1;
M_1_max = (M_2_min - 1 - N21)*Sc_spacing_2/Sc_spacing_1 -N1;

M_3_min = (M_2_max + N22)*Sc_spacing_2/Sc_spacing_3 +N3 +1;
M_3_max = (M_2_max + N22)*Sc_spacing_2/Sc_spacing_3 +N3 +N_sc_3;
%% F-OFDM
snrdB = -10:2:10;
for i =1:1:length(snrdB)
%OFDM符号生成
M_1_seq = -(randi([0,1],N_sc_1,1).*2-1);
M_2_seq = -(randi([0,1],N_sc_2,1).*2-1);
M_3_seq = -(randi([0,1],N_sc_3,1).*2-1);

M_1_seq_symbol = [zeros(M_1_min-1,1);M_1_seq;zeros(N_fft_1-M_1_max,1)];
M_2_seq_symbol = [zeros(M_2_min-1,1);M_2_seq;zeros(N_fft_2-M_2_max,1)];
M_3_seq_symbol = [zeros(M_3_min-1,1);M_3_seq;zeros(N_fft_3-M_3_max,1)];

sequence1_ifft = ifft(M_1_seq_symbol,N_fft_1)*sqrt(N_fft_1);
sequence2_ifft = ifft(M_2_seq_symbol,N_fft_2)*sqrt(N_fft_2);
sequence3_ifft = ifft(M_3_seq_symbol,N_fft_3)*sqrt(N_fft_3);

%加CP
cpLen_1_6 = 144;
cpLen_1_1 = 160;
cpLen_2_4 = 200;
cpLen_2_1 = 224;
cpLen_3_3 = 2048;
cpLen_3_1 = 2048;

txSigOFDM_1_slot = [sequence1_ifft(end-cpLen_1_1+1:end); sequence1_ifft;repmat([sequence1_ifft(end-cpLen_1_6+1:end); sequence1_ifft],N_symbol_1-1,1)]; 
txSigOFDM_2_slot = [sequence2_ifft(end-cpLen_2_1+1:end); sequence2_ifft;repmat([sequence2_ifft(end-cpLen_2_4+1:end); sequence2_ifft],N_symbol_2-1,1)]; 
txSigOFDM_3_slot = repmat([sequence3_ifft(end-cpLen_3_3+1:end); sequence3_ifft],N_symbol_3,1); 

%发送滤波
data_after_filter_1=upfirdn(repmat(txSigOFDM_1_slot,1/Time_1,1),rrcFilterNum_M_1,1); 
data_after_filter_2=upfirdn(repmat(txSigOFDM_2_slot,1/Time_2,1),rrcFilterNum_M_2,1); 
data_after_filter_3=upfirdn(repmat(txSigOFDM_3_slot,1/Time_3,1),rrcFilterNum_M_3,1); 

data_sum = data_after_filter_1((length(rrcFilterNum_M_1)-1)/2+1:end-((length(rrcFilterNum_M_1)-1)/2))...
         + data_after_filter_2((length(rrcFilterNum_M_2)-1)/2+1:end-((length(rrcFilterNum_M_2)-1)/2))...
         + data_after_filter_3((length(rrcFilterNum_M_3)-1)/2+1:end-((length(rrcFilterNum_M_3)-1)/2));
% wvtool(data_sum);
% fvtool(data_sum);
%awgn
data_sum_channel = awgn(data_sum, snrdB(i), 'measured');
fprintf('snrdB = %d\n',snrdB(i));
%接收滤波1
data_rx_filter_1=upfirdn(data_sum_channel,rrcFilterNum_M_1,1); 
data_rx_filter_1_final = data_rx_filter_1((length(rrcFilterNum_M_1)-1)/2+1:end-((length(rrcFilterNum_M_1)-1)/2));
data_rx_filter_1_final_7 = reshape(data_rx_filter_1_final,length(data_rx_filter_1_final)*Time_1,1/Time_1);
data_rx_filter_1_final_7_1 = reshape(data_rx_filter_1_final_7(cpLen_1_1-cpLen_1_6+1:end,:),cpLen_1_6+N_fft_1,N_symbol_1/Time_1);
data_rx_filter_1_final_7_2 = data_rx_filter_1_final_7_1(cpLen_1_6+1:end,:);
data_rx_1_symbol_1_f = fft(data_rx_filter_1_final_7_2,N_fft_1)/sqrt(N_fft_1);
data_rx_1_symbol_f_real = ((real(data_rx_1_symbol_1_f(M_1_min:M_1_max,:))>0).*2-1)==repmat(M_1_seq,1,N_symbol_1/Time_1);
ErrorSample_1(i) = (numel(data_rx_1_symbol_f_real)-sum(sum(data_rx_1_symbol_f_real)))/numel(data_rx_1_symbol_f_real);
fprintf('Ber1 = %.6f\n',ErrorSample_1(i));
%接收滤波2
data_rx_filter_2=upfirdn(data_sum_channel,rrcFilterNum_M_2,1); 
data_rx_filter_2_final = data_rx_filter_2((length(rrcFilterNum_M_2)-1)/2+1:end-((length(rrcFilterNum_M_2)-1)/2));
data_rx_filter_2_final_5 = reshape(data_rx_filter_2_final,length(data_rx_filter_2_final)*Time_2,1/Time_2);
data_rx_filter_1_final_5_1 = reshape(data_rx_filter_2_final_5(cpLen_2_1-cpLen_2_4+1:end,:),cpLen_2_4+N_fft_2,N_symbol_2/Time_2);
data_rx_filter_1_final_5_2 = data_rx_filter_1_final_5_1(cpLen_2_4+1:end,:);
data_rx_2_symbol_2_f = fft(data_rx_filter_1_final_5_2,N_fft_2)/sqrt(N_fft_2);
data_rx_2_symbol_f_real = ((real(data_rx_2_symbol_2_f(M_2_min:M_2_max,:))>0).*2-1)==repmat(M_2_seq,1,N_symbol_2/Time_2);
ErrorSample_2(i) = (numel(data_rx_2_symbol_f_real)-sum(sum(data_rx_2_symbol_f_real)))/numel(data_rx_2_symbol_f_real);
fprintf('Ber2 = %.6f\n',ErrorSample_2(i));
%接收滤波3
data_rx_filter_3=upfirdn(data_sum_channel,rrcFilterNum_M_3,1); 
data_rx_filter_3_final = data_rx_filter_3((length(rrcFilterNum_M_3)-1)/2+1:end-((length(rrcFilterNum_M_3)-1)/2));
data_rx_filter_3_final_3 = reshape(data_rx_filter_3_final,length(data_rx_filter_3_final)*Time_3,1/Time_3);
data_rx_filter_3_final_3_1 = reshape(data_rx_filter_3_final_3(cpLen_3_1-cpLen_3_3+1:end,:),cpLen_3_3+N_fft_3,N_symbol_3/Time_3);
data_rx_filter_3_final_3_2 = data_rx_filter_3_final_3_1(cpLen_3_3+1:end,:);
data_rx_3_symbol_3_f = fft(data_rx_filter_3_final_3_2,N_fft_3)/sqrt(N_fft_3);
data_rx_3_symbol_f_real = ((real(data_rx_3_symbol_3_f(M_3_min:M_3_max,:))>0).*2-1)==repmat(M_3_seq,1,N_symbol_3/Time_3);
ErrorSample_3(i) = (numel(data_rx_3_symbol_f_real)-sum(sum(data_rx_3_symbol_f_real)))/numel(data_rx_3_symbol_f_real);
fprintf('Ber3 = %.6f\n',ErrorSample_3(i));
end
%% BER曲线
figure;
plot(snrdB,ErrorSample_1,'-sb',snrdB,ErrorSample_2,'-*b',snrdB,ErrorSample_3,'-ob');
title('\fontname{宋体}误码率曲线');
grid on;
xlim([-10,10]);
legend('\fontname{times new roman}F-OFDM \fontname{宋体}子带\fontname{times new roman}1','\fontname{times new roman}F-OFDM \fontname{宋体}子带\fontname{times new roman}2','\fontname{times new roman}F-OFDM \fontname{宋体}子带\fontname{times new roman}3');
xlabel('\fontname{times new roman}SNR/dB');ylabel('\fontname{times new roman}BER');
set(gca,'xtick',snrdB);
  • M_1
function Hd = M_1
%M_1 Returns a discrete-time filter object.

% MATLAB Code
% Generated by MATLAB(R) 9.7 and Signal Processing Toolbox 8.3.
% Generated on: 23-Jul-2020 20:08:56

% FIR Window Bandpass filter designed using the FIR1 function.

% All frequency values are in kHz.
Fs = 30720;  % Sampling Frequency

Fstop1 = 1350;              % First Stopband Frequency
Fpass1 = 1440;              % First Passband Frequency
Fpass2 = 2160;              % Second Passband Frequency
Fstop2 = 2250;              % Second Stopband Frequency
Dstop1 = 0.00031622776602;  % First Stopband Attenuation
Dpass  = 0.057501127785;    % Passband Ripple
Dstop2 = 0.00031622776602;  % Second Stopband Attenuation
flag   = 'scale';           % Sampling Flag

% Calculate the order from the parameters using KAISERORD.
[N,Wn,BETA,TYPE] = kaiserord([Fstop1 Fpass1 Fpass2 Fstop2]/(Fs/2), [0 ...
                             1 0], [Dstop1 Dpass Dstop2]);

% Calculate the coefficients using the FIR1 function.
b  = fir1(N, Wn, TYPE, kaiser(N+1, BETA), flag);
Hd = dfilt.dffir(b);

% [EOF]

  • M_2
function Hd = M_2
%M_2 Returns a discrete-time filter object.

% MATLAB Code
% Generated by MATLAB(R) 9.7 and Signal Processing Toolbox 8.3.
% Generated on: 23-Jul-2020 20:10:59

% FIR Window Bandpass filter designed using the FIR1 function.

% All frequency values are in kHz.
Fs = 30720;  % Sampling Frequency

N    = 1366;     % Order
Fc1  = 2205;     % First Cutoff Frequency
Fc2  = 3015;     % Second Cutoff Frequency
flag = 'scale';  % Sampling Flag
% Create the window vector for the design algorithm.
win = hann(N+1);

% Calculate the coefficients using the FIR1 function.
b  = fir1(N, [Fc1 Fc2]/(Fs/2), 'bandpass', win, flag);
Hd = dfilt.dffir(b);

% [EOF]

  • M_3
function Hd = M_3
%M_3.M Returns a discrete-time filter object.

% MATLAB Code
% Generated by MATLAB(R) 9.7 and Signal Processing Toolbox 8.3.
% Generated on: 23-Jul-2020 20:01:09

% FIR Window Bandpass filter designed using the FIR1 function.

% All frequency values are in kHz.
Fs = 30720;  % Sampling Frequency

N    = 4096;     % Order
Fc1  = 3015;     % First Cutoff Frequency
Fc2  = 3825;     % Second Cutoff Frequency
flag = 'scale';  % Sampling Flag
% Create the window vector for the design algorithm.
win = blackmanharris(N+1);

% Calculate the coefficients using the FIR1 function.
b  = fir1(N, [Fc1 Fc2]/(Fs/2), 'bandpass', win, flag);
Hd = dfilt.dffir(b);

% [EOF]

F-OFDM 系统简单Matlab搭建_第1张图片

微信公众号:通信随笔XIDIAN

在这里插入图片描述

你可能感兴趣的:(Matlab,通信)