Home of RF and Wireless Vendors and Resources

One Stop For Your RF and Wireless Need

AWGN impairment in MATLAB

This section of MATLAB source code covers AWGN impairment and AWGN effect on constellation diagram using matlab code.

Generating complex vector-PART A

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');

AWGN impairment addition-PART B

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');

data_mapping.m-PART C

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

>>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 diagram

constellation input
AWGN effect on constellation

Useful Links to MATLAB codes

Refer following as well as links mentioned on left side panel for useful MATLAB codes.
OFDM Preamble generation  Time off estimation corr  Freq off estimation corr  channel estimation  11a WLAN channel  PN sequence generation  OFDMA Tx Rx  AES DES  carrier aggregation  CCDF  FIR Filter  IIR Filter  Low Pass FIR  Viterbi decoder  CRC8 CRC32 

RF and Wireless tutorials

WLAN  802.11ac  802.11ad  wimax  Zigbee  z-wave  GSM  LTE  UMTS  Bluetooth  UWB  IoT  satellite  Antenna  RADAR 


Share this page

Translate this page