qam.m
来自「Matlab时频分析工具箱,希望能对大家有所帮助啊」· M 代码 · 共 60 行
M
60 行
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.% This program is free software: you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation, either version 3 of the License, or% (at your option) any later version.% % This program is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% GNU General Public License for more details.% % You should have received a copy of the GNU General Public License% along with this program. If not, see <http://www.gnu.org/licenses/>.% 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 + -
显示快捷键?