function [d] = modulace(b__, type)

modBit = 0;

switch type
    case 'BPSK'
        modBit = 1;
    case 'QPSK'
        modBit = 2;
    case '16QAM'
        modBit = 4;
    case '64QAM'
        modBit = 6;
end

if(mod(length(b__),modBit)~=0),
    fillBits = mod(length(b__),modBit);
    b__ = [b__ zeros(1,fillBits)];
end


switch type
    case 'BPSK'
        % vytvoření modulátoru
        bpskMod = modem.pskmod('M', 2, 'PhaseOffset', pi/4, ...
                  'SymbolOrder', 'user-defined','SymbolMapping',[0 1], ...
                  'InputType', 'bit');
        % vytvoření demodulatoru
        bpskdeMod = modem.pskdemod(bpskMod);
        d = modulate(bpskMod,b__')./sqrt(2);
    case 'QPSK'
        qpskMod = modem.pskmod('M', 4, 'PhaseOffset', pi/4, ...
                  'SymbolOrder', 'user-defined','SymbolMapping',[0 2 3 1], ...
                  'InputType', 'bit');
        % vytvoření demodulatoru
        qpskdeMod = modem.pskdemod(qpskMod);
        d = modulate(qpskMod,b__');
    case '16QAM'
        QAM16mod = modem.qammod('M', 16,  ...
                  'SymbolOrder', 'user-defined', 'SymbolMapping',...
                  [11 10 14 15  9  8 12 13 ...
                    1  0  4  5  3  2  6  7], ...
                  'InputType', 'bit');
        % vytvoření demodulatoru
        QAM16demod = modem.qamdemod(QAM16mod);
        d = modulate(QAM16mod,b__')./sqrt(10);
    case '64QAM'
        QAM64mod = modem.qammod('M', 64,  ...
                  'SymbolOrder', 'user-defined', 'SymbolMapping', ...
                  [47 46 42 43 59 58 62 63 ...7
                   45 44 40 41 57 56 60 61 ...15
                   37 36 32 33 49 48 52 53 ...23
                   39 38 34 35 51 50 54 55 ...31
                   ...
                   7  6  2  3  19 18 22 23 ...39
                   5  4  0  1  17 16 20 21 ...47
                   13 12 8  9  25 24 28 29 ...55
                   15 14 10 11 27 26 30 31 ...63
                  ], ...
                  'InputType', 'bit');
        % vytvoření demodulatoru
        QAM64demod = modem.qamdemod(QAM64mod);
        d = modulate(QAM64mod,b__')./sqrt(42);
end