plot the eye diagram without using eyediagram() in matlab

To plot the eye diagram of a signal in Matlab, we can plot multiple instances of the signal after certain time intervals. Here are the steps to plot the eye diagram of a signal called x:

  1. Create a window of a certain length win_len and a certain offset offset. The window length win_len represents the time range for which we want to observe the signal (typically the bit time), and the window offset is the time delay at which we start observing the signal (typically half the bit time).
main.m
win_len = 50;  % window length
offset = 25;  % window offset
61 chars
3 lines
  1. Calculate the number of windows num_win.
main.m
num_win = floor((length(x)-win_len)/offset);
45 chars
2 lines
  1. Define the horizontal axis t_axis for the plot as well as the vertical axis v_axis.
main.m
t_axis = 1:win_len;  % horizontal axis
v_axis = (-1:2/15:1);  % vertical axis
78 chars
3 lines
  1. Create a new figure and plot each window of the signal on top of each other using a for loop. We can use the hold on command to plot each window as a separate line on the same figure.
main.m
figure
hold on
for i = 1:num_win
    win_start = (i-1)*offset + 1;
    plot(t_axis, x(win_start:win_start+win_len-1), 'b')
end
grid on
axis([t_axis(1),t_axis(end),v_axis(1),v_axis(end)])
xlabel('Time')
ylabel('Amplitude')
title('Eye Diagram')
243 chars
12 lines

The resulting plot will be the eye diagram of the signal x, where the horizontal axis represents time and the vertical axis represents amplitude.

related categories

gistlibby LogSnag