主程序:
clc;
clear all;
close all;
ebn0=0:30;
% [qber,qreal]=qpsk(ebn0);
[qber_f,qreal_f]=qpsk_fading(ebn0);
figure(1)
semilogy(ebn0,qber_f,'-*b',ebn0,qreal_f,'-om','LineWidth',2);
xlabel('Eb/N0(dB)')
ylabel('BER')
title('Performance of QPSK')
legend('QPSK Rayleigh(Simulation)','QPSK Rayleigh(Theory)')
axis([0 30 1.00E-5 1.00E+0])
grid on;
子程序1:
% qpsk_fading.m
%
% Simulation program to realize QPSK transmission system
% (under one path fading)
%
% Programmed by H.Harada and T.Yamamura
%
%******************** Preparation part *************************************
function [ber_f,real_f]=qpsk_fading(ebn0)
sr=256000.0; % Symbol rate
ml=2; % ml:Number of modulation levels (BPSK:ml=1, QPSK:ml=2, 16QAM:ml=4)
br=sr .* ml; % Bit rate
nd = 100; % Number of symbols that simulates in each loop
lth=length(ebn0); % Eb/N0
IPOINT=8; % Number of oversamples
ber_f=zeros(1,lth);
real_f=(1-1./sqrt(1+1./10.^(ebn0/10)))/2;
%************************* Filter initialization ***************************
irfn=21; % Number of taps
alfs=0.5; % Rolloff factor
[xh] = hrollfcoef(irfn,IPOINT,sr,alfs,1); %Transmitter filter coefficients
[xh2] = hrollfcoef(irfn,IPOINT,sr,alfs,0); %Receiver filter coefficients
%******************* Fading initialization ********************
% If you use fading function "sefade", you can initialize all of parameters.
% Otherwise you can comment out the following initialization.
% The detailed explanation of all of valiables are mentioned in Program 2-8.
% Time resolution
tstp=1/sr/IPOINT; %采样周期
% Arrival time for each multipath normalized by tstp
% If y