Kelly Boswell wrote:
> All,
>
> I recently had to create a library replacement of qammod.m in the
> communications toolbox, because it doesn't allow for non-square (power
> of 4) symbol sets and that was desired for my project.  Here is what I
> have:
>
> my_qammod.m:
>
> function [y] = my_qammod(x, M, qam_type)
>       
>     switch(qam_type)
>         case 1
>             error('qammod type %d is undefined', qam_type);
>             exit;
>
>         case 3
>             if (nargin < 2)
>                 usage('y = my_qammod(x,m,type)');
>                 exit;
>             end
>             if (M ~= fix(M))
>                 error('m must be an integer power of 2 > 4');
>                 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)))
>                 switch(M)
>                     case 8
>                         a = [ -1,  1, ...
>                               -1,  1, ...
>                               -1,  1, ...
>                               -1,  1];
>
>                         b = [  3,  3, ...
>                                1,  1, ...
>                               -1, -1, ...
>                               -3, -3];
>
>                         c = a + i*b;
>                         y = c(x + 1);
>                     case 32
>                         a = [    -3, -1, 1, 3, ...
>                              -5, -3, -1, 1, 3, 5, ...
>                              -5, -3, -1, 1, 3, 5, ...
>                              -5, -3, -1, 1, 3, 5, ...
>                              -5, -3, -1, 1, 3, 5, ...
>                                  -3, -1, 1, 3];
>
>                         b = [     5,  5,  5,  5, ...
>                               3,  3,  3,  3,  3,  3, ...
>                               1,  1,  1,  1,  1,  1, ...
>                              -1, -1, -1, -1, -1, -1, ...
>                              -3, -3, -3, -3, -3, -3, ...
>                                  -5, -5, -5, -5];
>
>                         c = a + i*b;
>                         y = c(x + 1);
>                     case 128
>                         a = [           -7,  -5,  -3,  -1,   1,   3,
> 5,   7, ...
>                                         -7,  -5,  -3,  -1,   1,   3,
> 5,   7, ...
>                                -11, -9, -7,  -5,  -3,  -1,   1,   3,
> 5,   7,   9,  11, ...
>                                -11, -9, -7,  -5,  -3,  -1,   1,   3,
> 5,   7,   9,  11, ...
>                                -11, -9, -7,  -5,  -3,  -1,   1,   3,
> 5,   7,   9,  11, ...
>                                -11, -9, -7,  -5,  -3,  -1,   1,   3,
> 5,   7,   9,  11, ...
>                                -11, -9, -7,  -5,  -3,  -1,   1,   3,
> 5,   7,   9,  11, ...
>                                -11, -9, -7,  -5,  -3,  -1,   1,   3,
> 5,   7,   9,  11, ...
>                                -11, -9, -7,  -5,  -3,  -1,   1,   3,
> 5,   7,   9,  11, ...
>                                -11, -9, -7,  -5,  -3,  -1,   1,   3,
> 5,   7,   9,  11, ...
>                                         -7,  -5,  -3,  -1,   1,   3,
> 5,   7, ...
>                                         -7,  -5,  -3,  -1,   1,   3,   5,   
> 7];
>
>                         b = [           11,  11,  11,  11,  11,  11,
> 11,  11, ...
>                                          9,   9,   9,   9,   9,   9,
> 9,   9, ...
>                                7,   7,   7,   7,   7,   7,   7,   7,
> 7,   7,   7,   7, ...
>                                5,   5,   5,   5,   5,   5,   5,   5,
> 5,   5,   5,   5, ...
>                                3,   3,   3,   3,   3,   3,   3,   3,
> 3,   3,   3,   3, ...
>                                1,   1,   1,   1,   1,   1,   1,   1,
> 1,   1,   1,   1, ...
>                               -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
> -1,  -1,  -1,  -1, ...
>                               -3,  -3,  -3,  -3,  -3,  -3,  -3,  -3,
> -3,  -3,  -3,  -3, ...
>                               -5,  -5,  -5,  -5,  -5,  -5,  -5,  -5,
> -5,  -5,  -5,  -5, ...
>                               -7,  -7,  -7,  -7,  -7,  -7,  -7,  -7,
> -7,  -7,  -7,  -7 ...
>                                         -9,  -9,  -9,  -9,  -9,  -9,
> -9,  -9, ...
>                                        -11, -11, -11, -11, -11, -11, -11, 
> -11];
>
>                         c = a + i*b;
>                         y = c(x + 1);
>                     otherwise
>                         error('qammod for M = %d is undefined', M);
>                         exit;
>
>                 end
>             else
>                 b = -2.*mod(x,(c)) + c-1;
>                 a = 2.*floor(x./(c)) - c+1;
>                 y = a + i.*b;
>             end
>
>         otherwise
>             error('qammod type %d is undefined', qam_type);
>             exit;
>     end
>
> end
>
> It's basically a copy of what was already there, except I added
> special cases for each non-square, like 8, 32, etc.  I also added a
> "type" which for QAM could be type I, II, or III.  Square
> constellations are type III and are the most common.  However, type
> I's can be useful in fading situations, so I may add that
> functionality later.  Basically, type I's are circular constellations,
> and they're useful in fading channels if you use a differential coding
> scheme.
>
> You can use the qamdemod that already exists in the communications
> package, though you may have to change the reference to "qammod" to be
> "my_qamdemod" or rename this file and put it in a path that is at a
> higher priority than your communications package.
>
> Please let me know what you think.
>
>   

Have you looked at the qaskenco function? This was a Matlab R13 function 
that mathworks replaced in later versions of their communications 
toolbox.. It would make sense to implement qammod /qamdemodproperly 
perhaps using qaskenco/qaskdeco (that I tried a few years back to make 
as fast as I could) a these do try 8-QAM, 32-QAM, etc

D.

-- 
David Bateman                                dbate...@dbateman.org
35 rue Gambetta                              +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE            +33 6 72 01 06 33 (Mob)


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to