Binary phase shift keying | Scigyan

Binary phase shift keying

Matlab program for Binary phase shift keying.

Matlab code

clc;clear all;close all;
A1=1;   %Amplitude of Carrier Wave
fc=input('Enter the frequency of carrier wave(fc)= ');
n=input('Enter the no of bit= ');
r=input('Enter the Bite Rate (In bits/sec)= ');
tpb=1/r; %Time duration for per bit
x=rand(1,n); x
   for i=1:length(x)
       if x(i)>=0.5
           B(i)=1;
       else
           B(i)=0;
       end;
   end;
B  
t1=0;         %Temporary variable for time
st=[];         %Variable for store time
Sbs=[];      %Variable for store Bit stream
Sbpsk=[];  %Variable for store bpsk signal
for i=1:length(B)
    if B(i)==0                                    % When bit is 0 --
        t=t1:0.001:t1+tpb;                   % for time duration tpb behaviour of--
        Bs=zeros(1,length(t));             % Bit stream and--
        bpsk=A1*sin(2*pi*fc*t+pi);  % bpsk signal.
    else
        t=t1:0.001:t1+tpb;
        Bs=ones(1,length(t));
        bpsk=A1*sin(2*pi*fc*t);
    end;
    st=[st t];                       %storing tpb duration of time
    Sbs=[Sbs Bs];             %storing Bit stream in tpb duration
    Sbpsk=[Sbpsk bpsk];  %storing bpsk signal in tpb duration
    t1=t1+tpb;                   %initial value of next tpb duration for iteration
end;
Sc=A1*sin(2*pi*fc*st);  %Carrier Wave
subplot(4,1,1);
plot(st,Sbs);
axis([0 tpb*n -2 2])
xlabel('Time');ylabel('Amplitude');title('Bit stream');
subplot(4,1,2);
plot(st,Sc);
xlabel('Time');ylabel('Amplitude');title('Carrier wave');
subplot(4,1,3);
plot(st,Sbpsk);
xlabel('Time');ylabel('Amplitude');title('BPSK Signal');
subplot(4,1,4);
plot(st,Sbs);
axis([0 tpb*n -2 2])
hold on;
plot(st,Sbpsk,'-.r');
xlabel('Time');ylabel('Amplitude');title('Bit stream and BPSK Signal');
h=legend('Bit stream','BPSK Signal');

Command window

Enter the frequency of carrier wave (fc) = 1
Enter the no of bit = 15
Enter the Bite Rate (In bits/sec) = 1
x =
  Columns 1 through 9
    0.8147    0.9058    0.1270    0.9134    0.6324    0.0975    0.2785    0.5469    0.9575
  Columns 10 through 15
    0.9649    0.1576    0.9706    0.9572    0.4854    0.8003
B =
     1     1     0     1     1     0     0     1     1     1     0     1     1     0     1

Figure window

Binary-phase-shift-keying
No comments:
Post a Comment

Related Posts Plugin for WordPress, Blogger...