Robochameleon  v1.0
sd_kmeans.m
1 function [symb, centroids]= sd_kmeans(X,c)
2 % K-means soft decision digital demodulation
3 %
4 % SYMB = DD_KMEANS(X,C)
5 %
6 % X - input constellation points
7 % C - reference constellation
8 % SYMB - demodulated symbols
9 % centroids - Cluster centers
10 % Robert Borkowski, rbor@fotonik.dtu.dk
11 % Technical University of Denmark
12 % Modified by Miguel Iglesias Olmedo, miguelio@kth.se
13 % v3.0, 10 October 2015
14 
15 s = warning('error','stats:kmeans:FailedToConverge'); % Change error to warning
16 try
17  options = struct('MaxIter',15);
18  [symb, centroids] = kmeans(X,numel(c),'onlinephase','off','options',options,'start',c,'emptyaction','singleton');
19 catch exception
20  switch exception.identifier
21  case 'stats:kmeans:FailedToConverge'
22  % warning('K-means did not converge. Using hard-decision.');
23  symb = hd_euclid(X,c);
24  centroids = c;
25  otherwise
26  rethrow(exception);
27  end
28 end
29 warning(s); % Reenable error(?)
30 
31 symb = uint16(symb(:));
function hd_euclid(in X, in c)
Euclidean metric hard decision digital demodulation.