Robochameleon  v1.0
bits2symb.m
1 function symb = bits2symb(bits,M,bitorder)
2 
3 if ~islogical(bits)
4  error('Bits must be of type logical.');
5 end
6 
7 if nargin<2 || isempty(M) % if M not specified, or is an empty matrix
8  log2M_ = size(bits,1); % log2(M) is equal to first dimension of bits matrix
9 else % M specified
10  log2M_ = log2M(M); % log2(M) is computed from M
11  N = size(bits,1);
12  if all(size(bits)>1) && N~=log2M_ %% if given a matrix whose first dimension disagrees with log2(M) of given M
13  error('First dimension of input bit matrix (%d) does not agree with log2(M) (%d).',N,log2M_);
14  end
15  bits = reshape(bits,log2M_,[]);
16 end
17 
18 if nargin<3
19  bitorder = 'lsb-first'; % if bitorder not specified, assume LSB is first
20 end
21 mult = 2.^(0:log2M_-1)'; % multipliers for LSB
22 if strcmpi(bitorder,'msb-first') % if order is MSB, flip multipliers
23  mult = flipud(mult);
24 elseif ~strcmpi(bitorder,'lsb-first')
25  % If order is not 'lsb-first' at this point, bitorder is neither of two
26  % available options => throw an error.
27  error('Bit order can be set to ''lsb-first'' (default) or ''msb-first''.');
28 end
29 
30 symb = uint16(sum(bsxfun(@times,bits,mult),1)')+1;
function N(in obj)
Retrieve the number of signal components.
function set(in obj, in varargin)
Set properties for the current object.
function end(in obj, in k, in n)
Overload of indexing end statement.