| |
% 主函数
% 调用各子函数,建立SC_FDE仿真平台
% 数据输入 -> 卷积编码 -> 矩阵交织 -> QPSK调制 -> 插入导频 -> 插入CP -> RayleighFading
% channel -> AWGN channel -> 去除CP -> FDE -> QPSK解调 -> 矩阵去交织 -> Viterbi译码
%-------------------------------------------------------------------------%
% Clearing Workspace %
%-------------------------------------------------------------------------%
clear all;
clc;
close all;
%-------------------------------------------------------------------------%
% Seeting the parameters %
%-------------------------------------------------------------------------%
M = 5; %仿真运行的信噪比点数
FrameSize = 512; %每帧信息比特的大小
FrameNum = 100; %发送的数据帧数
interleave_table = interleav_matrix( ones(1,2*FrameSize) ); %产生交织码表
UW_Num = 64; %独特字UW的大小
UW_Ge = UW_Generate( UW_Num ); %产生独特字序列
trel = poly2trellis( 7,[171 133] ); %产生trelis
tblen = 5*7; %Traceback depth
Ts = 1/480000; %输入Rayleigh channel的信号采样时间(s)
Fd = 4; %Rayleigh channel的最大多普勒频移(HZ)
tau = [0 2.6*10^-7]; %Rayleigh channel的路径延时向量(s)
pdb = [0 -3]; %Rayleigh channel的路径增益向量(dB)
Rayleigh_chan = rayleighchan( Ts,Fd,tau,pdb ); %Generate Rayleigh channel
% t = scatterplot(0); %Initialize scatter plot
% h = scatterplot(0); %Initialize scatter plot
BER_arry = zeros(16,FrameNum);
for SNR = 0:2:20
%---------------------------------------------------------------------%
% SC-FDE %
%---------------------------------------------------------------------%
for ii = 1:1:FrameNum
%-----------------------------------------------------------------%
% Generate Transmit Signal & Convolutional Code %
% & Matrix Interleaver & QPSK modulator %
%-----------------------------------------------------------------%
BitsTranstmp = randint(1,FrameSize);
conv_out = convenc( BitsTranstmp,trel );
interleav_out = interleaving( conv_out,interleave_table );
QPSK_out = psk( interleav_out,2 );
%-----------------------------------------------------------------%
% QPSK_out -> insetting pilot -> insetting CP %
%-----------------------------------------------------------------%
Signal_Tx = [UW_Ge,QPSK_out,UW_Ge];
%-----------------------------------------------------------------%
% Signal_Tx -> Rayleigh channel -> AWGN channel %
%-----------------------------------------------------------------%
Rayleigh_chan_out = filter( Rayleigh_chan,Signal_Tx );
Signal_Rx = awgn( Rayleigh_chan_out,SNR );
%-----------------------------------------------------------------%
% Signal_Rx -> Deleting CP -> MMSE_FDE %
%-----------------------------------------------------------------%
FDE_in = Signal_Rx( 1,1:(size(Signal_Rx,2)-UW_Num) );
FDE_out = MMSE_FDE( FDE_in,UW_Ge );
%-----------------------------------------------------------------%
% FDE_out -> QPSK Demodulator -> Matrix Deinterleaver -> Viterbi %
%-----------------------------------------------------------------%
% h = scatterplot( FDE_out,1,0,'b.',h); %plot the new plot
% axis([-3 3 -3 3]); %Adjust axis limits
% title('scatter plot - after FDE');
% grid;
% drawnow; %refresh the image
deqpsk_out = de_qpsk( FDE_out );
deinterleav_out = de_interleaving( deqpsk_out,interleave_table );
viterbi_out = vitdec( deinterleav_out,trel,tblen,'cont','hard' );
%-----------------------------------------------------------------%
% Computing the BER %
%-----------------------------------------------------------------%
decoded = viterbi_out(tblen+1:end);
msg = BitsTranstmp(1:end-tblen);
[n,r] = biterr( decoded,msg );
% disp(['The bit error rate is: ',num2str(r)]);
BER_arry(SNR/2+1,ii) = r;
end
Ber(SNR/2+1) = sum( BER_arry(SNR/2+1,:) )/FrameNum;
disp(['The SNR(dB) is : ',num2str(SNR), ' The BER is : ',num2str(Ber(SNR/2+1))]);
end
Snr = 0:2:20;
figure;
semilogy(Snr,Ber,'--*');
grid on;
xlabel('SNR (dB)');
ylabel('BER');
title('SC-FDE rate 1/2 conv code QPSK');
hold off
————————————————
版权声明:本文为CSDN博主「FPGA&matlab」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/ccsss22/article/details/119959582