% define parameters N = 3; % (2*N)^2 - QAM % create QAM symbol stream B = BitStream(20004); x = BitToSymbolStream(B,N); X = QAM_Mod(x,N); % add noise at specified SNR level SNR = 20; sigma_x = std(X); noise = (randn(1,length(X)) + sqrt(-1)*randn(1,length(X)))/sqrt(2); X = X + sigma_x*10^(-SNR/20)*noise; % recovery of bit stream y = QAM_Demod(X,N); B2 = SymbolToBitStream(y,N); % determining the number of bit errors and BER BER = norm(B-B2,1)/length(B); disp(sprintf('BER = %f %',BER*100));