1 ## Copyright (C) 2003 David Bateman
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
17 ## @deftypefn {Function File} {} apkconst (@var{nsig})
18 ## @deftypefnx {Function File} {} apkconst (@var{nsig},@var{amp})
19 ## @deftypefnx {Function File} {} apkconst (@var{nsig},@var{amp},@var{phs})
20 ## @deftypefnx {Function File} {} apkconst (@var{...},"n")
21 ## @deftypefnx {Function File} {} apkconst (@var{...},@var{str})
22 ## @deftypefnx {Function File} {@var{y} = } apkconst (@var{...})
24 ## Plots a ASK/PSK signal constellation. Argument @var{nsig} is a real vector
25 ## whose length determines the number of ASK radii in the constellation.
26 ## The values of vector @var{nsig} determine the number of points in each
29 ## By default the radii of each ASK modulated level is given by the index of
30 ## @var{nsig}. The amplitudes can be defined explictly in the variable
31 ## @var{amp}, which is a vector of the same length as @var{nsig}.
33 ## By default the first point in each ASK radii has zero phase, and following
34 ## points are coding in an anti-clockwise manner. If @var{phs} is defined then
35 ## it is a vector of the same length as @var{nsig} defining the initial phase
38 ## In addition @dfn{apkconst} takes two string arguments 'n' and and @var{str}.
39 ## If the string 'n' is included in the arguments, then a number is printed
40 ## next to each constellation point giving the symbol value that would be
41 ## mapped to this point by the @dfn{modmap} function. The argument @var{str}
42 ## is a plot style string (example 'r+') and determines the default gnuplot
43 ## point style to use for plot points in the constellation.
45 ## If @dfn{apskconst} is called with a return argument, then no plot is
46 ## created. However the return value is a vector giving the in-phase and
47 ## quadrature values of the symbols in the constellation.
49 ## @seealso{dmod,ddemod,modmap,demodmap}
52 ## 2005-04-23 Dmitri A. Sergatskov <dasergatskov@gmail.com>
53 ## * modified for new gnuplot interface (octave > 2.9.0)
57 function yout = apkconst(varargin)
59 if ((nargin < 1) || (nargin > 5))
60 error ("apkconst: incorrect number of arguments");
69 for i=1:length(varargin)
92 error ("apkconst: too many numerical arguments");
98 error ("apkconst: must have at least one vector argument");
102 amp = 1:length(nsig);
106 phs = zeros(size(amp));
109 if (!isvector(nsig) || !isvector(amp) || !isvector(phs) || ...
110 (length(nsig) != length(amp)) || (length(nsig) != length(phs)))
111 error ("apkconst: numerical arguments must be vectors of the same length");
114 if (length(nsig) == 0)
115 error ("apkconst: first numerical argument must have non-zero length");
121 error ("apkconst: must have at least one point in ASK radii");
123 y = [y; amp(i) * [cos(2*pi*[0:nsig(i)-1]'/nsig(i) + phs(i)) + ...
124 1i*sin(2*pi*[0:nsig(i)-1]'/nsig(i) + phs(i))]];
132 yy = [real(y), imag(y)];
135 xd = 0.05 * max(real(y));
137 text(real(y(i))+xd,imag(y(i)),num2str(i-1));
140 plot (real(y), imag(y), fmt);
142 title("ASK/PSK Constellation");
144 ylabel("Quadrature");