qam.m

来自「linear time-frequency toolbox」· M 代码 · 共 47 行

M
47
字号
function xo=qam(xi,order)%QAM  QAM modulation of input signal.%    Usage:  xo=qam(xi,order);%%    xi must be a vector of 0's and 1's. %    order must be a power of 2.% Verify inputif ~all((xi==0) + (xi==1))  error('Input vector must consist of only 0s and 1s');end;if mod(log2(order),1)~=0  error('order must be a power of 2.');end;% Get the optimal ordering of bitsbitorder=circbitflip(order);% nbits is number of bits used. Everything will be ordered% in groups of this size.nbits=log2(order);L=length(xi);symbols=L/nbits;% nbits must divide Lif rem(symbols,1)~=0  error('Length of input must be a multiple of log2(order)');end;xi=reshape(xi,nbits,symbols);two_power=(2.^(0:nbits-1)).';% This could be vectorized by a repmat.xo=zeros(symbols,1);for ii=1:symbols  xo(ii)=sum(xi(:,ii).*two_power);end;% xo now consist of numbers in the range 0:order-1% Convert to the corresponding complex root of unity.xo=exp(2*pi*i*bitorder(xo+1)/order);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?