image thumbnail

Phase Shift Keying(PSK)

by

 

09 Aug 2010 (Updated )

This is the code for Phase shift keying...

PSK.m
% % % % % % % % % % % % % % % % % % % % % % % Code for Phase Shift Keying
% % % % % % % % % % % % % % % % % % % % % % % % Code By:- Debaraj Rana

% % % % % % % % % % % % % % % % % % % % % % % % mail- debaraj.rana@ymail.com
% % % % % % % % % % % % % % % % % % % % % % % % Dept. Of Electronics & Telecom. Engg
% % % % % % % % % % % % % % % % % % % % % % % % VSSUT, Burla,ORISSA


clc;clear all;close all;
mat=input('Enter The Input data Sequence : ');
sig1=(2*mat)-1;                     % mat converted to matrix of 1 and -1 form
len=length(sig1);                     % length of input data seq.
x=0:1/10:len*2*pi;
y=sin(x);                           % sinusoidal signal
len1=length(y);
len2=len1/len;                      % l2 is the length of one period of signal
j=1;

for i=1:len
   for k=1:len2
           z(j)=y(j)*sig1(i);       % multiply signal with corresponding bits
           sig(j)=sig1(i);          % stretch the data sequence
           k=k+1;
           j=j+1;
   end
  i=i+1;
end
ln=length(sig);
for i=1:ln
    if sig(i)<0
       sig(i)=0;
    end
end    
subplot(3,1,1);
stairs(sig,'linewidth',2); % display data sequence
axis([0 ln -2 3]);
title('Input data Sequence');
ylabel('Amplitude--->');
xlabel('Time--->');
subplot(3,1,2);
plot(y);axis([0 ln -1 1]);                            %plot sinusoidal signal
title('Sinusoidal Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
subplot(3,1,3);
plot(z); axis([0 ln -1 1]);                           %plot the psk modulated signal
title('PSK Modulated Signal');
ylabel('Amplitude--->');
xlabel('Time--->');


 l0=length(y); 
 l1=length(z);
 for i=1:l1
     y1(i)=y(i);                   % Make both PSK signal matrix and carrier of same size
 end
 
 % Demodulation Of PSK signal
 for i=1:l1
      dsig(i)=y1(i)*z(i);          % Multiply with carrier
  end
%   figure
%   plot(dsig);
  
 % Process to make as 0 and 1 sequence
  for i=1:l1
     if dsig(i)>0
        dsig2(i)=1
     else
        dsig2(i)=0;
     end    
 end
 figure
  stairs(dsig2,'linewidth',2); axis([0 ln -2 3]);
 title('Demodulated data Sequence');
 ylabel('Amplitude--->');
 xlabel('Time--->');

Contact us