ECE 409 COMPUTER ASSIGNMENT #1 DR. JAMES S.
KANG
1. Use MATLAB to plot the signal constellation of the following modulation.
(a) QPSK
(b) 8 PSK
(c) 16 PSK
(d) 32 PSK
(e) 64 PSK
(f) 128 PSK
(g) 256 PSK
2. Use MATLAB to plot the signal constellation of the following modulation.
(a) 8 QAM
(b) 16 QAM
(c) 32 QAM
(d) 64 QAM
(e) 128 QAM
(f) 256 QAM
Hint:
8 PSK
M=8;
x=[0:M-1];
y = pskmod(x,M,[],'gray');
scatterplot(y,1,0,'b.');
hold on;
annot = dec2bin([0:length(y)-1],log2(M));
text(real(y)+0.15,imag(y),annot);
axis([-4 4 -4 4]);
title('Constellation for Gray-Coded 8-PSK');
hold off;
8 QAM
M = 8;
x = [0:M-1];
y = qammod(x,M,[],'gray');
scatterplot(y,1,0,'b.');
hold on;
annot = dec2bin([0:length(y)-1],log2(M));
text(real(y)+0.15,imag(y),annot);
axis([-4 4 -4 4]);
1
title('Constellation for Gray-Coded 8-QAM');
hold off;
pskmod
Phase shift keying modulation
Syntax
y = pskmod(x,M)
y = pskmod(x,M,ini_phase)
y = pskmod(x,M,ini_phase,symbol_order)
Description
y = pskmod(x,M) outputs the complex envelope y of the modulation of the message
signal x using phase shift keying modulation. M is the alphabet size and must be an
integer power of 2. The message signal must consist of integers between 0 and M-1. The
initial phase of the modulation is zero. If x is a matrix with multiple rows and columns,
then the function processes the columns independently.
y = pskmod(x,M,ini_phase) specifies the initial phase of the modulation in radians.
y = pskmod(x,M,ini_phase,symbol_order) specifies how the function assigns binary
words to corresponding integers. If symbol_order is set to 'bin' (default), the function will
use a natural binary-coded ordering. If symbol_order is set to 'gray', it will use a Gray
constellation ordering.
qammod
Quadrature amplitude modulation
Syntax
y = qammod(x,M)
y = qammod(x,M,ini_phase)
y = qammod(x,M,ini_phase,symbol_order)
Description
y = qammod(x,M) outputs the complex envelope y of the modulation of the message
signal x using quadrature amplitude modulation. M is the alphabet size and must be an
integer power of 2. The message signal must consist of integers between 0 and M-1. The
signal constellation is rectangular or cross-shaped, and the nearest pair of points in the
constellation is separated by 2. If x is a matrix with multiple rows, then the function
processes the columns independently.
2
y = qammod(x,M,ini_phase) specifies the initial phase of the modulated signal in radians.
y = qammod(x,M,ini_phase,symbol_order) specifies how the function assigns binary
words to corresponding integers. If symbol_order is set to 'bin' (default), the function will
use a natural binary-coded ordering. If symbol order is set to 'gray', it will use a Gray
constellation ordering.
scatterplot
Generate scatter plot
Syntax
scatterplot(x)
scatterplot(x,n)
scatterplot(x,n,offset)
scatterplot(x,n,offset,plotstring)
scatterplot(x,n,offset,plotstring,h)
h = scatterplot(...)
Description
scatterplot(x) produces a scatter plot for the signal x. The interpretation of x depends on
its shape and complexity:
If x is a real two-column matrix, then scatterplot interprets the first column as in-phase
components and the second column as quadrature components.
If x is a complex vector, then scatterplot interprets the real part as in-phase components
and the imaginary part as quadrature components.
If x is a real vector, then scatterplot interprets it as a real signal.
scatterplot(x,n) is the same as the first syntax, except that the function plots every nth
value of the signal, starting from the first value. That is, the function decimates x by a
factor of n before plotting.
scatterplot(x,n,offset) is the same as the first syntax, except that the function plots every
nth value of the signal, starting from the (offset+1)st value in x.
scatterplot(x,n,offset,plotstring) is the same as the syntax above, except that plotstring
determines the plotting symbol, line type, and color for the plot. plotstring is a string
whose format and meaning are the same as in the plot function.
3
scatterplot(x,n,offset,plotstring,h) is the same as the syntax above, except that the scatter
plot is in the figure whose handle is h, rather than a new figure. h must be a handle to a
figure that scatterplot previously generated. To plot multiple signals in the same figure,
use hold on.
h = scatterplot(...) is the same as the earlier syntaxes, except that h is the handle to the
figure that contains the scatter plot.
dec2bin
Convert decimal to binary number in string
Syntax
str = dec2bin(d)
str = dec2bin(d,n)
Description
str = dec2bin(d) returns the binary representation of d as a string. d must be a nonnegative
integer smaller than 2^52.
str = dec2bin(d,n) produces a binary representation with at least n bits.
text
Create text object in current axes
Syntax
text(x,y,'string')
text(x,y,z,'string')
text(...'PropertyName',PropertyValue...)
h = text(...)
Description
text is the low-level function for creating text graphics objects. Use text to place character
strings at specified locations.
text(x,y,'string') adds the string in quotes to the location specified by the point (x,y).
text(x,y,z,'string') adds the string in 3-D coordinates.
text(x,y,z,'string','PropertyName',PropertyValue....) adds the string in quotes to the
location defined by the coordinates and uses the values for the specified text properties.
See the text property list section at the end of this page for a list of text properties.
4
text('PropertyName',PropertyValue....) omits the coordinates entirely and specifies all
properties using property name/property value pairs.
h = text(...) returns a column vector of handles to text objects, one handle per object. All
forms of the text function optionally return this output argument.
See the String property for a list of symbols, including Greek letters.