AWGN Impairment Simulation in MATLAB

This article provides MATLAB source code demonstrating Additive White Gaussian Noise (AWGN) impairment and its effect on constellation diagrams.

PART A: Generating a Complex Vector

This section generates a complex vector representing the modulated signal.

clc;
clear all;
close all;

len=input('Enter the length of the payload:');
mod=input('Enter 1 for bpsk, 2 for qpsk, 4 for 16qam, 6 for 64qam:(default:4)');

if mod==1
    c1=sqrt(1);
elseif mod==2
    c1=sqrt(1/2);
elseif mod==4
    c1=sqrt(1/10);
elseif mod==6
    c1=sqrt(1/42);
else
    printf('wrong entry');
end

%This part will generate binary vector as per length entered by user
data=floor(rand(1,len)+0.5);

%Mapping of binary data
mapper_out=data_mapping(data',mod,c1);
mapper_out_ori=mapper_out;

figure;
plot(real(mapper_out_ori),imag(mapper_out_ori),'r+');
title('ideal constellation');


## PART B: AWGN Impairment Addition

This section adds AWGN to the generated signal and displays the resulting constellation diagram.

```matlab
%AWGN impairment addition
snr=input('Enter SNR:');
map_out_awgn=awgn(mapper_out,snr,'measured');

figure;
plot(real(map_out_awgn),imag(map_out_awgn),'r+');
title('constellation with Added AWGN');

PART C: data_mapping.m Function

This is the code for the data_mapping.m function, which performs the digital modulation.

function [map_out]=data_mapping(data,mode,fact)

input_seq = data;

switch mode
    case 1
        b=fact*[1 -1];
    case 2
        b=fact*[1+1i -1+1i 1-1i -1-1i];
    case 4
        b=fact*[1+1i 1+3i 1-1i 1-3i 3+1i 3+3i 3-1i 3-3i -1+1i -1+3i -1-1i -1-3i -3+1i -3+3i -3-1i -3-3i];
    case 6
        b=fact*[3+3i 3+1i 3+5i 3+7i 3-3i 3-1i 3-5i 3-7i 1+3i 1+1i 1+5i 1+7i 1-3i 1-1i 1-5i 1-7i 5+3i 5+1i 5+5i 5+7i 5-3i 5-1i 5-5i 5-7i 7+3i 7+1i 7+5i 7+7i 7-3i 7-1i 7-5i 7-7i -3+3i -3+1i -3+5i -3+7i -3-3i -3-1i -3-5i -3-7i -1+3i -1+1i -1+5i -1+7i -1-3i -1-1i -1-5i -1-7i -5+3i -5+1i -5+5i -5+7i -5-3i -5-1i -5-5i -5-7i -7+3i -7+1i -7+5i -7+7i -7-3i -7-1i -7-5i -7-7i];
    otherwise
        error('wrong choice');
end

count=1;
count1=1 ;

for i=1:(ceil(length(input_seq)/mode))
    temp=0;
    for j=1:mode
        temp=bitor(temp,bitshift(input_seq(count),(j-1)));
        count=count+1;
        if(count>length(input_seq))
            break;
        end
    end
    map_out(count1)=b(temp+1);
    count1=count1+1;
end

Input Parameters

Example of input parameters used in the MATLAB code:

>> Enter the length of the payload:1000
>> Enter 1 for bpsk, 2 for qpsk, 4 for 16qam, 6 for 64qam:(default:4): 4
>> Enter SNR: 30

Input and Output Constellation Diagrams

Here are the constellation diagrams generated by the code, illustrating the impact of AWGN:

constellation input image

AWGN effect on constellation