changeset 3962:df5297d90ce9 octave-forge

Initial Commit Into CVS.
author sis-sou
date Thu, 18 Oct 2007 06:27:45 +0000
parents c616f0a26786
children 537bfa60d683
files main/comm/inst/qamdemod.m main/comm/inst/qammod.m
diffstat 2 files changed, 84 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/comm/inst/qamdemod.m	Thu Oct 18 06:27:45 2007 +0000
@@ -0,0 +1,40 @@
+## Copyright (C) 2007   Sylvain Pelissier   <sylvain.pelissier@gmail.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} qamdemod (@var{x},@var{m})
+## Create the QAM demodulation of x with a size of alphabet m.
+## @seealso{qammod,pskmod,pskdemod}
+## @end deftypefn
+
+function z = qamdemod(y,m)
+    if(nargin < 2)
+	usage('y = qamdemod(x,m)');
+	exit;
+   end
+    
+    c = sqrt(m);
+    if(c ~= fix(c)  || log2(c) ~= fix(log2(c)))
+        error('m must be a square of a power of 2');
+        exit;
+    end
+    
+    x = my_qammod(0:(m-1),m);
+    x = reshape(x,1,m);
+    for k = 1:length(y)
+        [n z(k)] = min(abs(y(k) - x));
+        z(k) = z(k) - 1;
+    end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/comm/inst/qammod.m	Thu Oct 18 06:27:45 2007 +0000
@@ -0,0 +1,44 @@
+## Copyright (C) 2007   Sylvain Pelissier   <sylvain.pelissier@gmail.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Function File} qammod (@var{x},@var{m})
+## Create the QAM modulation of x with a size of alphabet m.
+## @seealso{qamdemod,pskmod,pskdemod}
+## @end deftypefn
+
+function y = qammod(x,m)
+   if(nargin < 2)
+	usage('y = qammod(x,m)');
+	exit;
+   end
+   if(any(x >= m))
+        error('values of x must be in range [0,M-1]');
+        exit;
+    end
+    
+    if(~any(x == fix(x)))
+        error('values of x must be integer');
+        exit;
+    end
+    c = sqrt(m);
+    if(c ~= fix(c)  || log2(c) ~= fix(log2(c)))
+        error('m must be a square of a power of 2');
+        exit;
+    end
+    b = -2.*mod(x,(c))+c-1;
+    a = 2.*floor(x./(c))-c+1;
+    y = a + i.*b;
\ No newline at end of file