Frequency shift keying | Scigyan

Frequency shift keying

Matlab program for Frequency shift keying.

Matlab code

clc;clear all;close all;
A1=1;   %Amplitude of Carrier Wave
fc1=input('Enter the frequency for bit 0 of carrier wave(fc1)= ');
fc2=input('Enter the frequency for bit 1 of carrier wave(fc2)= ');
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
Sfsk=[];  %Variable for store fsk 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--
        fsk=A1*sin(2*pi*fc1*t);   % fsk signal.
    else
        t=t1:0.001:t1+tpb;
        Bs=ones(1,length(t));
        fsk=A1*sin(2*pi*fc2*t);
    end;
    st=[st t];                 %storing tpb duration of time
    Sbs=[Sbs Bs];        %storing Bit stream in tpb duration
    Sfsk=[Sfsk fsk];     %storing fsk signal in tpb duration
    t1=t1+tpb;             %initial value of next tpb duration for iteration
end;
Sc1=A1*sin(2*pi*fc1*st); %1st Carrier Wave
Sc2=A1*sin(2*pi*fc2*st); %2nd 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,Sc1);
xlabel('Time');ylabel('Amplitude');title('1st Carrier wave');
subplot(4,1,3);
plot(st,Sc2);
xlabel('Time');ylabel('Amplitude');title('2nd Carrier wave');
subplot(4,1,4);
plot(st,Sfsk);
xlabel('Time');ylabel('Amplitude');title('FSK Signal');

Command window

Enter the frequency for bit 0 of carrier wave (fc1) = 5
Enter the frequency for bit 1 of carrier wave (fc2) = 10
Enter the no of bit= 10
Enter the Bite Rate (In bits/sec) = 1
x =
  Columns 1 through 9
    0.7943    0.3112    0.5285    0.1656    0.6020    0.2630    0.6541    0.6892    0.7482
  Column 10
    0.4505
B =
     1     0     1     0     1     0     1     1     1     0

Figure window

Frequency-shift-keying
No comments:
Post a Comment

Related Posts Plugin for WordPress, Blogger...