useprbs = 0; M = 4; randkey = 2; fsym = 112e9; %%%%% PRBS Generation in correct shape for Modulation Format %%%%%% O = 18; %order of prbs N = 2^(O-1); %length of prbs [~,seed] = prbs(O,1); %initialize first seed of prbs bitpattern=[]; if useprbs for i = 1:log2(M) [bitpattern(:,i),seed] = prbs(O,N,seed); end else s = RandStream('twister','Seed',randkey); for i = 1:log2(M) bitpattern(:,i) = randi(s,[0 1], N, 1); end end if M == 6 bitpattern = reshape(bitpattern,[],1); bitpattern = bitpattern(1:end-mod(length(bitpattern),5)); end Tx_bits = Informationsignal(bitpattern); Digi_Mod = PAMmapper(M,0); Symbols_tx = Digi_Mod.map(Tx_bits); Symbols_tx.fs = fsym; if 0 Symbols = Duobinary().precode(Symbols_tx); Symbols = Duobinary().encode(Symbols); Symbols = MLSE("DIR",[1 1],"duobinary_output",1,"trellis_states",Digi_Mod.levels,"M",M).process(Symbols); Symbols = Duobinary().decode(Symbols); else cnt = 1; Symbols = Symbols_tx; coeff = [1,0.5,0.2,0.1]; Symbols.signal = filter(coeff, 1, Symbols.signal); Symbols.spectrum("fignum",129,"displayname",['coeff:',num2str(coeff)]); Symbols = MLSE("DIR",coeff,"duobinary_output",0,"trellis_states",Digi_Mod.levels,"M",M).process(Symbols); Rx_bits = PAMmapper(M,0).demap(Symbols); [~,error_num,ber,error_pos] = calc_ber(Tx_bits.signal,Rx_bits.signal,"skip_front",0,"skip_end",0,"returnErrorLocation",1); disp(['BER: ',sprintf('%.1E',ber),' - - PAM-',num2str(M)]); end % figure(494) clf subplot(2,1,1) title('Bits Compare') hold on stairs(Rx_bits.signal(1:100,1),'LineWidth',2,'DisplayName','Rx Bits') stairs(Tx_bits.signal(1:100,1),'LineStyle',':','LineWidth',2,'DisplayName','Tx Bits'); legend subplot(2,1,2) hold on title('Symbols Compare') stairs(Symbols.signal(1:100,1),'LineStyle','-','LineWidth',2,'DisplayName','Rx Symbols'); stairs(Symbols_tx.signal(1:100,1),'LineWidth',2,'DisplayName','Tx Symbols','LineStyle',':') legend