Amplitude shift keying | Scigyan

Amplitude shift keying

Matlab program for Amplitude shift keying.

Matlab code

clc;clear all;close all;
A1=0;   %Amplitude of Carrier Wave when bit=0
A2=1;   %Amplitude of Carrier Wave when bit=1
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
Sask=[];   %Variable for store ask 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--
        ask=A1*sin(2*pi*fc*t); % ask signal.
    else
        t=t1:0.001:t1+tpb;
        Bs=ones(1,length(t));
        ask=A2*sin(2*pi*fc*t);
    end;
    st=[st t];                       %storing tpb duration of time
    Sbs=[Sbs Bs];             %storing Bit stream in tpb duration
    Sask=[Sask ask];         %storing ask signal in tpb duration
    t1=t1+tpb;                   %initial value of next tpb duration for iteration
end;
Sc=A2*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,Sask);
xlabel('Time');ylabel('Amplitude');title('ASK Signal');
subplot(4,1,4);
plot(st,Sbs,'-.');
axis([0 tpb*n -2 2])
hold on;
plot(st,Sask);
xlabel('Time');ylabel('Amplitude');title('Bit stream and ASK Signal');
h=legend('Bit stream','ASK Signal');

Command window

Enter the frequency of carrier wave (fc) = 2
Enter the no of bit = 10
Enter the Bite Rate (In bits/sec) = 1
x =
  Columns 1 through 9
    0.8308    0.5853    0.5497    0.9172    0.2858    0.7572    0.7537    0.3804    0.5678
  Column 10
    0.0759
B =
     1     1     1     1     0     1     1     0     1     0

Figure window

Amplitude-shift-keying
No comments:
Post a Comment

Related Posts Plugin for WordPress, Blogger...