The Matlab Programme for BPSK.
clc;
close all;
clear all;
input=[1 0 1 0 0 1 1];
rb=10;
fs=16*rb;
ts=1/fs;
tb=1/rb;
p=length(input);
amplitude=1;
for count=1:length(input)
for temptime=1:16
if input(count)==0
output(count,temptime)=-1*amplitude;
else
output(count,temptime)=1*amplitude;
end
end
end
k1=reshape(output',1,112);
t=0:ts:tb*(length(input))-ts;
subplot(2,2,1);
plot(t,k1);
xlabel('Time');
ylabel('Amplitude');
title('Input Data');
axis([0 .7 -1.5 1.5]);
fc=10e4;
t1=0:9/(112*fc):9/fc-(.03/fc);
y=cos(2*pi*fc*t1);
subplot(2,2,2);
plot(t1,y);
xlabel('Time');
ylabel('Amplitude');
title('Carrier Signal');
z=k1.*y;
subplot(2,2,3);
plot(t1,z);
xlabel('time')
ylabel('Amplitude')
title('BPSK Modulated Signal')
n=awgn(z,10);
subplot(2,2,4);
plot(t1,n);
xlabel('time');
ylabel('Amplitude');
title('BPSK Noisy Signal');
%BPSK Rx multiplying the recieved signal with reference ossicator
v=z.*y;
k5=length(v);
%Integration
integrationbase=0:1/fs:tb-1/fs;
for i=0:(length(v)/(tb*fs))-1
w(i+1)=trapz(integrationbase,v(int32(i*tb*fs+1):int32((i+1)*tb*fs)));
end
for i=0:(k5/(tb*fs))-1
if(w(i+1)>0)
output1(i+1)=1;
else
output1(i+1)=0;
end
end
final_output=output1
DOWNLOAD
1. MATLAB FILE
2. SNAPSHOT
Shivam Kotwalia
clc;
close all;
clear all;
input=[1 0 1 0 0 1 1];
rb=10;
fs=16*rb;
ts=1/fs;
tb=1/rb;
p=length(input);
amplitude=1;
for count=1:length(input)
for temptime=1:16
if input(count)==0
output(count,temptime)=-1*amplitude;
else
output(count,temptime)=1*amplitude;
end
end
end
k1=reshape(output',1,112);
t=0:ts:tb*(length(input))-ts;
subplot(2,2,1);
plot(t,k1);
xlabel('Time');
ylabel('Amplitude');
title('Input Data');
axis([0 .7 -1.5 1.5]);
fc=10e4;
t1=0:9/(112*fc):9/fc-(.03/fc);
y=cos(2*pi*fc*t1);
subplot(2,2,2);
plot(t1,y);
xlabel('Time');
ylabel('Amplitude');
title('Carrier Signal');
z=k1.*y;
subplot(2,2,3);
plot(t1,z);
xlabel('time')
ylabel('Amplitude')
title('BPSK Modulated Signal')
n=awgn(z,10);
subplot(2,2,4);
plot(t1,n);
xlabel('time');
ylabel('Amplitude');
title('BPSK Noisy Signal');
%BPSK Rx multiplying the recieved signal with reference ossicator
v=z.*y;
k5=length(v);
%Integration
integrationbase=0:1/fs:tb-1/fs;
for i=0:(length(v)/(tb*fs))-1
w(i+1)=trapz(integrationbase,v(int32(i*tb*fs+1):int32((i+1)*tb*fs)));
end
for i=0:(k5/(tb*fs))-1
if(w(i+1)>0)
output1(i+1)=1;
else
output1(i+1)=0;
end
end
final_output=output1
DOWNLOAD
1. MATLAB FILE
2. SNAPSHOT
Shivam Kotwalia
No comments:
Post a Comment