clear all;
close all;
clc;
fc=1000;                                % Frequency for "0" bits
t=linspace(0,1/1000,50);
 
e0=sin(2*pi*fc*t);                 % BPSK output for "1"  
e1=-sin(2*pi*fc*t);                % BPSK output for "0"
 
b=mod(randperm(16),2);
bnot=1-b;
n=['The binary data is   ',num2str(b)];
bpsk1=[ ];bpsk2=[ ];bin=[ ];

for i=1:length(b)
    bpsk1=[bpsk1,b(i)*e0];
    bpsk2=[bpsk2,bnot(i)*e1];
    bin=[bin,b(i)*ones(1,50)];
end;

bpskout=bpsk1+bpsk2;
tm=[0:length(bpsk1)-1];

plot(tm,bin,'r--');
axis([0 length(bin) 0 1.5]);
hold on;
 
plot(tm,bpskout,'b');
axis([0 length(tm) -1.5 1.5]);
hold off;

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: