0% found this document useful (0 votes)
230 views

Eye Diagrams

The document contains code to generate and plot eye diagrams for QPSK signals with raised cosine pulse shaping using different rolloff factors (α = 0.5 and α = 1). It generates random binary data, upsamples it, filters it with raised cosine filters for each rolloff factor, and plots the real part of the filtered signals over 2 symbol periods to display the eye diagrams.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
230 views

Eye Diagrams

The document contains code to generate and plot eye diagrams for QPSK signals with raised cosine pulse shaping using different rolloff factors (α = 0.5 and α = 1). It generates random binary data, upsamples it, filters it with raised cosine filters for each rolloff factor, and plots the real part of the filtered signals over 2 symbol periods to display the eye diagrams.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

y= x(15:length(x)); % remove any initial transient

M= fix(length(y)/8);

y= y(1:M*8)

A= reshape(y,8,M); % matrix A has M columns of length 8 taken from y

plot(A),grid

Fs = 1.024*10^6;

Rs = 256*10^3;

ns = Fs/Rs;

rolloff = 0.2;

M = 4;

qpskMod = comm.QPSKModulator; % comm.QPSKModulator System object

rctFilt = comm.RaisedCosineTransmitFilter('RolloffFactor', rolloff, ...

'OutputSamplesPerSymbol', ns, ...

'FilterSpanInSymbols', 6, ...

'Gain', 1);

% Generate modulated and pulse shaped signal

frameLen = 2000;

msgData = randi([0 M-1],frameLen,1);

msgSymbols = qpskMod(msgData);

msgTx = rctFilt(msgSymbols);

t = 0:1/Fs:500/Rs-1/Fs;

idx = round(t*Fs+1);
hFig = figure;

plot(t, real(msgTx(idx)));

hold on;

title('Modulated, filtered in-phase signal');

xlabel('Time (sec)');

ylabel('Amplitude');

grid on;

managescattereyefig(hFig);

% Create an eye diagram object

eyeObj = commscope.eyediagram(...

'SamplingFrequency', Fs, ...

'SamplesPerSymbol', 4, ...

'OperationMode', 'Complex Signal', ...

'SymbolsPerTrace', 2)

% Update the eye diagram object with the transmitted signal

update(eyeObj, 0.5*msgTx);

% Manage the figures

managescattereyefig(hFig, eyeObj, 'right');

% Script for plotting the eye diagram where transmit filtering


% is performed by raised cosine filtering with alpha=0.5, alpha=1.

clear
N = 10^3; % number of symbols
am = 2*(rand(1,N)>0.5)-1 + j*(2*(rand(1,N)>0.5)-1); % generating random
binary sequence
fs = 10; % sampling frequency in Hz

% defining the sinc filter


sincNum = sin(pi*[-fs:1/fs:fs]); % numerator of the sinc function
sincDen = (pi*[-fs:1/fs:fs]); % denominator of the sinc function
sincDenZero = find(abs(sincDen) < 10^-10);
sincOp = sincNum./sincDen;
sincOp(sincDenZero) = 1; % sin(pix/(pix) =1 for x =0

% raised cosine filter


alpha = 0.5;
cosNum = cos(alpha*pi*[-fs:1/fs:fs]);
cosDen = (1-(2*alpha*[-fs:1/fs:fs]).^2);
cosDenZero = find(abs(cosDen)<10^-10);
cosOp = cosNum./cosDen;
cosOp(cosDenZero) = pi/4;

gt_alpha5 = sincOp.*cosOp;

alpha = 1;
cosNum = cos(alpha*pi*[-fs:1/fs:fs]);
cosDen = (1-(2*alpha*[-fs:1/fs:fs]).^2);
cosDenZero = find(abs(cosDen)<10^-10);
cosOp = cosNum./cosDen;
cosOp(cosDenZero) = pi/4;
gt_alpha1 = sincOp.*cosOp;

% upsampling the transmit sequence


amUpSampled = [am;zeros(fs-1,length(am))];
amU = amUpSampled(:).';

% filtered sequence
st_alpha5 = conv(amU,gt_alpha5);
st_alpha1 = conv(amU,gt_alpha1);

% taking only the first 10000 samples


st_alpha5 = st_alpha5([1:10000]);
st_alpha1 = st_alpha1([1:10000]);

st_alpha5_reshape = reshape(st_alpha5,fs*2,N*fs/20).';
st_alpha1_reshape = reshape(st_alpha1,fs*2,N*fs/20).';

close all
figure;
plot([0:1/fs:1.99],real(st_alpha5_reshape).','b');
title('eye diagram with alpha=0.5');
xlabel('time')
ylabel('amplitude')
axis([0 2 -1.5 1.5])
grid on

figure;
plot([0:1/fs:1.99],real(st_alpha1_reshape).','b');
title('eye diagram with alpha=1')
xlabel('time')
ylabel('amplitude')
axis([0 2 -1.5 1.5 ])
grid on

You might also like