www.gusucode.com > UWB_matlab源码程序 > CP0203/cp0203_qpsk_mod.m

    %
% FUNCTION 2.10 : "cp0203_qpsk_mod"
%
% This function receives a binary stream in input ('bits')
% and returns the corresponding sequence of QPSK symbols
%  ('S'),
% plus the two sequences 'Sc' and 'Ss' containing the real
% and imaginary part of each symbol
%
% Programmed by Guerino Giancola
%

function [S,Sc,Ss] = cp0203_qpsk_mod(bits)

nb = length(bits);      % number of bits
ns = ceil(nb/2);        % number of symbols

b0 = zeros(1,ns*2);     % zero padding
b0(1:nb) = bits;

j = sqrt(-1);

for s = 1 : ns
    
    ba = b0(((s-1)*2)+1);
    bb = b0(((s-1)*2)+2);
    k = bb + ba*2;
    p = ((pi/4)*(2*k-1))-pi;
    
    Sc(s) = cos(p);
    Ss(s) = sin(p);
    S(s) = Sc(s) + j*Ss(s);
    
end