Robochameleon  v1.0
getClusters.m
1 function c = getClusters( M, coding, shape, phi )
2 
3 if strcmp(shape,'star')
4  phase1=0 + phi;
5  phase2=2*pi/M + phi;
6  r1 = 1*exp(1j*phase1); % first radius
7  r2 = 2*exp(1j*phase2); % second radius
8  c = [ r1*exp(1i*2*pi/(M/2)*(0:(M/2-1))) r2*exp(1i*2*pi/(M/2)*(0:(M/2-1)))];
9 elseif strcmp(shape,'linear')
10  c=linspace(-M/2, M/2, M);
11 elseif iswhole(sqrt(M)) && ~iswhole(log2(M))
12  % For QAM
13  c = (1:sqrt(M))*2;
14  c = c - mean(c);
15  c = sum(combvec(c,1j*c));
16  c = c*modnorm(c,'avpow',1);
17  c = [real(c); imag(c)]';
18  [theta, rho] = cart2pol(c(:,1),c(:,2));
19  [cx, cy] = pol2cart(theta + phi, rho);
20  c = cx+ 1i*cy;
21 else
22  c = qammod(0:M-1,M, phi, coding);
23 end
24 c = c*modnorm(c,'avpow',1);
25 c = c(:);
26 end
27 
function iswhole(in x, in tol)
Determine whether or not input is a whole number.