gusucode.com > matlab通信工程仿真源码(张德丰等编著)程序书籍 > matlab_code/matlab通信工程仿真源码(张德丰等编著)/第10章/Modulator.m
function [TxOut, PN, MF] = Modulator(chips, MFType, Walsh); %此函数用于实现IS-95前向链路系统的数据调制 % chips为发送的初始数据 % MFType为成型滤波器的类型选择 % Walsh为walsh码 % TxOut为调制输出信号序列 % PN为用于扩频调制的PN码序列 % MF为匹配滤波器参数 global Zi Zq show R Gi Gq N = length(chips)*length(Walsh); % 输入速率 = 19.2 KBps, 输出速率= 1.2288 Mcps tmp = sign(Walsh-1/2)*sign(chips'-1/2); chips = reshape(tmp, prod(size(tmp)), 1); [PNi Zi] = PNGen(Gi, Zi, N); [PNq Zq] = PNGen(Gq, Zq, N); PN = sign(PNi-1/2) + j*sign(PNq-1/2); chips_out = chips.*PN; chips = [chips_out, zeros(N, R-1)]; chips = reshape(chips.' , N*R, 1); %成型滤波器 switch (MFType) case 1 %升余弦滤波器 L = 25; L_2 = floor(L/2); n = [-L_2:L_2]; B = 0.7; MF = sinc(n/R).*(cos(pi*B*n/R)./(1-(2*B*n/R).^2)); MF = MF/sqrt(sum(MF.^2)); case 2 %矩形滤波器 L = R; L_2 = floor(L/2); MF = ones(L, 1); MF = MF/sqrt(sum(MF.^2)); case 3 %汉明滤波器 L = R; L_2 = floor(L/2); MF = hamming(L); MF = MF/sqrt(sum(MF.^2)); end MF = MF(:); TxOut = sqrt(R)*conv(MF, chips)/sqrt(2); TxOut = TxOut(L_2+1: end - L_2); if (show) figure; subplot(211); plot(MF, '-o'); title('Matched Filter'); grid on; subplot(212); psd(TxOut, 1024, 1e3, 113); title('Spectrum'); end