0% found this document useful (0 votes)
59 views2 pages

4-PSK Code: All All

This document describes a 4-PSK modulation and demodulation scheme. It generates random binary data, splits it into two streams to create 4-PSK symbols, modulates a carrier signal with the symbols, adds noise, and demodulates the signal using integration to recover the binary data and calculate the bit error rate (BER) over varying noise levels. The key steps are: 1) generating random binary data and splitting into two streams; 2) modulating a carrier signal with the 4-PSK symbols; 3) adding noise and recovering the symbols through integration; and 4) calculating the BER by comparing the received and transmitted bits.

Uploaded by

Eysha qureshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views2 pages

4-PSK Code: All All

This document describes a 4-PSK modulation and demodulation scheme. It generates random binary data, splits it into two streams to create 4-PSK symbols, modulates a carrier signal with the symbols, adds noise, and demodulates the signal using integration to recover the binary data and calculate the bit error rate (BER) over varying noise levels. The key steps are: 1) generating random binary data and splitting into two streams; 2) modulating a carrier signal with the 4-PSK symbols; 3) adding noise and recovering the symbols through integration; and 4) calculating the BER by comparing the received and transmitted bits.

Uploaded by

Eysha qureshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

4-PSK code

CODE:
clc
clear all
close all
a_db=2;
for k=1:10
total_bits=10; % total no of bits for simulation
display(' Binary information at Transmitter :');
b=(randn(1,total_bits)>0.5); %data generator to generate bits
disp(b);
u1=b(1:2:end); %split data into two data streams
u2=b(2:2:end);
c=cat(2,u1',u2'); %concatenate data into total_bits/2 rows and 2 columns
bp=0.000001;
A=5; % Amplitude of carrier signal
br=1/bp; % bit rate
f=br*2; % carrier frequency
t=bp/99:bp/99:bp;
s=[];
for i=1:total_bits/2 %modulate 1s and 0s into qpsk
if(c(i,:)==[1 0])
y=A*cos(2*pi*f*t+(pi/4));
elseif(c(i,:)==[0 0])
y=A*cos(2*pi*f*t+((3*pi)/4));
elseif(c(i,:)==[0 1])
y=A*cos(2*pi*f*t+((5*pi)/4));
else
y=A*cos(2*pi*f*t+((7*pi)/4));
end
s=[s y];
end
a=10^(a_db/10); % convert it into linear
n=(randn(1,length(s))+j*randn(1,length(s)))/sqrt(2*a); %noise
r = awgn(m,10);
r=s+n; %received signal
b1=cos(2*pi*f*t); % basis functions
b2=sin(2*pi*f*t);
d=[];
ss=length(t);
for n=ss:ss:length(s)
m1=b1.*s((n-(ss-1)):n);
m2=b2.*s((n-(ss-1)):n);
z1=trapz(t,m1); % integration
z2=trapz(t,m2);
if(z1>0 & z2>0)
a=[1 1];
elseif (z1>0 & z2<0)
a=[1 0];
elseif (z1<0 & z2>0)
a=[0 1];
else
a=[0 0];
end
d=[d a];
end
disp(' Binary information at Receiver :');
disp(d);
ber=sum(d~=b)/total_bits; % Count error and BER calculation
a_db=a_db+2; % increase the linear no to vary noise power
end

You might also like