Search This Blog

Thursday 29 October 2015

BASK


clc;
clear all;
close all;
fs=input('fs=');
fc=input('fc=');
bs=input('Bit sequence=');
L=length(bs);
A=[];
for i=1:L
    A=[A bs(i)*ones(1,fs)];
end
L1=length(A);
t=(10/L1):(10/L1):10;
C=sin(2*pi*fc*t);
BASK=C.*A;
subplot(2,2,1); plot(t,A); xlabel('Time'); ylabel('Level');
title('Bit sequence');
subplot(2,2,2); plot(t,C); xlabel('Time'); ylabel('Amplitude');
title('Carrier signal');
subplot(2,2,3); plot(t,BASK); xlabel('Time'); ylabel('Amplitude');
title('BASK Signal');
L2=length(BASK);
r=[];
for i=1:(L2/fs)
    if sum(abs(BASK((i-1)*fs+1:i*fs)),2)
        r=[r ones(1,fs)];
    else
        r=[r zeros(1,fs)];
    end
end
subplot(2,2,4); plot(t,r); xlabel('Time'); ylabel('Level');
title('Demodulated bit sequence')

No comments:

Post a Comment