The programme is to simulating the eyediagram in communication.
As we all know, eyediagram happens in the limited-band
communication because the aquare pulses expand their wave. In
addition, one pulse generates M-1 "eyes" in MPAM.
Following is the programme.
%++++++++++++++++++++++++++++++++++++++++++++++++++++
%For eyediagram
%Writer:MQ
�ta:2011.11.15
%++++++++++++++++++++++++++++++++++++++++++++++++++++
clc;
clear all;
close all;
%++++++++++++++++++++++++++++++++++++++++++++++++++++
%Input parameter
%++++++++++++++++++++++++++++++++++++++++++++++++++++
N_eye=6;% the number of 'eye'
N_code=1e3;% the number of bit
N_sample=10;% sample numbers during one pulse
Ts=1;% duration of one pulse
dt=Ts/N_sample; % sampling interval
N0=0.01; % PSD of AWGN
%++++++++++++++++++++++++++++++++++++++++++++++++++++
%Generate the DNRZ signal
%++++++++++++++++++++++++++++++++++++++++++++++++++++
%Gnerate random bits
bits=rand(1,N_code)>0.5;
%Generate DNRZ
for k=1:length(bits)
if
bits(k)==0
bit(k)=-1;
elseif
bits(k)==1
bit(k)=1;
end
end
signal=zeros(1,N_code*N_sample);
signal(1:N_sample:N_code*N_sample)=bit;
pulse=ones(1,N_sample);
signal_tr=conv(signal,pulse);
signal_tr=signal_tr(1:N_code*N_sample);
%++++++++++++++++++++++++++++++++++++++++++++++++++++
�nd-limited channel
%++++++++++++++++++++++++++++++++++++++++++++++++++++
t=0:dt:(N_code*N_sample*dt-dt);
channel_filter1=5/Ts*sinc(5*(t-5)/Ts);% BandWidth=2.5Hz
channel_filter2=2/Ts*sinc(2*(t-5)/Ts);% BandWidth=1Hz
channel_filter3=1/Ts*sinc(1*(t-5)/Ts);% BandWidth=0.5Hz
channel_filter4=0.5/Ts*sinc(0.5*(t-5)/Ts);% BandWidth=0.25Hz
% pass the channel
signal_tr1=dt*conv(signal_tr,channel_filter1);
signal_tr2=dt*conv(signal_tr,channel_filter2);
signal_tr3=dt*conv(signal_tr,channel_filter3);
signal_tr4=dt*conv(signal_tr,channel_filter4);
signal_tr1=[0,signal_tr1];
signal_tr2=[0,signal_tr2];
signal_tr3=[0,signal_tr3];
signal_tr4=[0,signal_tr4];
% add AWGN
sigma1=sqrt(2.5*N0);
noise1=normrnd(0,sigma1,size(signal_tr1));
signal_re1=signal_tr1+noise1;
sigma2=sqrt(1*N0);
noise2=normrnd(0,sigma2,size(signal_tr2));
signal_re2=signal_tr2+noise2;
sigma3=sqrt(0.5*N0);
noise3=normrnd(0,sigma3,size(signal_tr3));
signal_re3=signal_tr3+noise3;
sigma4=sqrt(0.25*N0);
noise4=normrnd(0,sigma1,size(signal_tr4));
signal_re4=signal_tr4+noise4;
%++++++++++++++++++++++++++++++++++++++++++++++++++++
%Graphic output
%++++++++++++++++++++++++++++++++++++++++++++++++++++
% draw the transfered signal
figure(1)
plot(t(1:50*N_sample),signal_tr(1:50*N_sample))
xlabel('Time [s]')
ylabel('Transfered Signal')
axis([-1,51,1.1*min(signal_tr),1.1*max(signal_tr)])
% draw the channel filter
figure(2)
plot(t,channel_filter1)
xlabel('Time [s]')
ylabel('Channel Filter')
% signal after channel
figure(3)
plot(t(N_eye*N_sample+1:2*N_eye*N_sample),signal_tr1(N_eye*N_sample+1:2*N_eye*N_sample))
xlabel('Time [s]')
ylabel('Signal after Channel')
% eyediagram
time=0:dt:N_eye*N_sample*dt-dt;
figure(4)
subplot(4,1,1)
for n=10:1:100
buffer=signal_re1(n*N_sample*N_eye+1:(n+1)*N_sample*N_eye);
drawnow;
plot(time,buffer);
hold
on;
end
ylabel('B=2.5Hz');
subplot(4,1,2)
for n=10:1:100
buffer=signal_re2(n*N_sample*N_eye+1:(n+1)*N_sample*N_eye);
drawnow;
plot(time,buffer);
hold
on;
end
ylabel('B=1Hz');
subplot(4,1,3)
for n=10:1:100
buffer=signal_re3(n*N_sample*N_eye+1:(n+1)*N_sample*N_eye);
drawnow;
plot(time,buffer);
hold
on;
end
ylabel('B=0.5Hz');
subplot(4,1,4)
for n=10:1:100
buffer=signal_re4(n*N_sample*N_eye+1:(n+1)*N_sample*N_eye);
drawnow;
plot(time,buffer);
hold
on;
end
ylabel('B=0.25Hz');
%++++++++++++++++++++++++++++++++++++++++++++++++++++
%Over
%++++++++++++++++++++++++++++++++++++++++++++++++++++
Any problems, please contact: 516139197@qq.com