Quadrature phase shift keying | Scigyan

Quadrature phase shift keying

Matlab program for Quadrature 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 (Multiples of 2) = ');
r=input('Enter the Bite Rate (In bits/sec) = ');
tpb=1/r; %Time duration for per bit
x=rand(1,n); x
   fori=1:length(x)
       ifx(i)>=0.5
           B(i)=1;
       else
           B(i)=0;
       end;
   end;
B  
t1=0;         %Temporary variable for time
st1=[];       %Variable for store time of bit stream
st2=[];       %Variable for store time of qpsk wave
Sbs=[];      %Variable for store Bit stream
Sqpsk=[];  %Variable for store qpsk signal
for i=1:length(B)
    ifB(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--
     else
        t=t1:0.001:t1+tpb;
        Bs=ones(1,length(t));
    end;
    st1=[st1 t];        % Storing tpb duration of time
    Sbs=[Sbs Bs];   % Storing Bit stream in tpb duration
    t1=t1+tpb;         % Initial value of next tpb duration for iteration
end;
t1=0;
for i=1:2:length(B)
    ifB(i)==0&&B(i+1)==0
        t=t1:0.001:t1+2*tpb;
        qpsk=A1*cos(2*pi*fc*t);
    elseifB(i)==0&&B(i+1)==1
        t=t1:0.001:t1+2*tpb;
        qpsk=A1*cos(2*pi*fc*t+pi/2);
    elseifB(i)==1&&B(i+1)==1
        t=t1:0.001:t1+2*tpb;
        qpsk=A1*cos(2*pi*fc*t+pi);  
    elseifB(i)==1&&B(i+1)==0
        t=t1:0.001:t1+2*tpb;
        qpsk=A1*cos(2*pi*fc*t+3*pi/2);
    end;
    st2=[st2 t];                 % Storing tpb duration of time
    Sqpsk=[Sqpsk qpsk]; % Storing qpsk signal in tpb duration
    t1=t1+2*tpb;              % Initial value of next tpb duration for iteration
end;
Sc=A1*cos(2*pi*fc*st2); %Carrier Wave
subplot(4,1,1);
plot(st1,Sbs);
axis([0 tpb*n -2 2])
xlabel('Time');ylabel('Amplitude');title('Bit stream');
subplot(4,1,2);
plot(st2,Sc);
xlabel('Time');ylabel('Amplitude');title('Carrier wave');
subplot(4,1,3);
plot(st2,Sqpsk);
xlabel('Time');ylabel('Amplitude');title('QPSK Signal');
subplot(4,1,4);
plot(st1,Sbs,'r');
axis([0 tpb*n -2 2])
hold on;
plot(st2,Sqpsk);
xlabel('Time');ylabel('Amplitude');title('Bit stream and QPSK Signal');
h=legend('Bit stream','QPSK Signal');

Command window

Enter the frequency of carrier wave (fc) = 3
Enter the no of bit (Multiples of 2) = 12
Enter the Bite Rate (In bits/sec) = 1
x =
  Columns 1 through 10
    0.9172    0.2858    0.7572    0.7537    0.3804    0.5678    0.0759    0.0540    0.5308    0.7792
  Columns 11 through 12
    0.9340    0.1299
B =
     1     0     1     1     0     1     0     0     1     1     1     0

Figure window

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

Related Posts Plugin for WordPress, Blogger...