Communications Toolbox | ![]() ![]() |
Eye Diagrams
An eye diagram is a simple and convenient tool for studying the effects of intersymbol interference and other channel impairments in digital transmission. To construct an eye diagram, plot the received signal against time on a fixed-interval axis. At the end of the fixed time interval, wrap around to the beginning of the time axis. Thus the diagram consists of many overlapping curves. One way to use an eye diagram is to look for the place where the "eye" is most widely opened, and use that point as the decision point when demapping a demodulated signal to recover a digital message.
To produce an eye diagram from a signal, use the eyediagram
function. The signal can have different formats, as the table below indicates.
Example: Eye Diagrams
The code below illustrates the use of the eye diagram for finding the best decision point. It maps a random digital signal to a 16-QASK waveform, then uses a raised cosine filter to simulate a noisy transmission channel. Several commands manipulate the filtered data to isolate its steady-state behavior. Then the eyediagram
command produces an eye diagram from the resulting signal.
% Define the M-ary number and sampling rates. M = 16; Fd = 1; Fs = 10; Pd = 100; % Number of points in the calculation msg_d = randint(Pd,1,M); % Random integers in the range [0,M-1] % Modulate using square constellation QASK method. msg_a = modmap(msg_d,Fd,Fd,'qask',M); % Assume the channel is equivalent to a raised cosine filter. delay = 3; % Delay of the raised cosine filter rcv = rcosflt(msg_a,Fd,Fs,'fir/normal',.5,delay); % Truncate the output of rcosflt to remove response tails. propdelay = delay .* Fs/Fd + 1; % Propagation delay of filter rcv1 = rcv(propdelay:end-(propdelay-1),:); % Truncated version N = Fs/Fd; % Plot the eye diagram of the resulting signal sampled and % displayed with no offset. offset1 = 0; h1 = eyediagram(rcv1,N,1/Fd,offset1); set(h1,'Name','Eye Diagram Displayed with No Offset');
Notice that a vertical line down the center of the diagram would cross the "eye" at its most widely opened point, as in the left-hand side below.
In the right-hand diagram above, a similar vertical line would not cross the eye at the most widely opened point. This diagram results from the commands
offset2 = 2; h2 = eyediagram(rcv1,N,1/Fd,offset2,'r-'); set(h2,'Name','Eye Diagram Displayed with Offset of Two');
This example continues by using the information gathered from the eye diagrams to choose the decision-timing offset in the demodmap
command. (Notice that the actual offset value in demodmap
is offset1+1
because eyediagram
and demodmap
express offsets in a different way.)
% Continue, using the offset information for digital demapping. newmsg1 = demodmap(rcv1,[Fd offset1+1],Fs,'qask',16); s1 = symerr(msg_d,newmsg1) % Number of symbol errors
By contrast, an offset value based on offset2
leads to errors in the recovered digital signal. Your exact number of errors might vary because the message msg_d
consists of random numbers.
As an additional example of using the eyediagram
function, the commands below display the eye diagram with no offset, but based on data that is sampled with an offset of two samples. This sampling offset simulates errors in timing that result from being two samples away from perfect synchronization.
h3 = eyediagram(rcv1(1+offset2:end,:),N,1/Fd,0); set(h3,'Name','Eye Diagram Sampled with Offset of Two');
![]() | Error Rates | Scatter Plots | ![]() |