Digital Modulation using Matlab

%ASK,FSK and PSK Modulation code in MATLAB

clc;
clear all;
close all;


x=[0 0 0 1 1 1 0 1 1 0 0 1 0 1 0 1 0 1];        % Binary Information
bp=.000001;                                     % bit period

d=100; %delay

%XX representation of transmitting binary information as digital signal XXX
bit=[]; 
for n=1:1:length(x)
    if x(n)==1;
       se=ones(1,d);
    else x(n)==0;
        se=zeros(1,d);
    end
     bit=[bit se];

end
t1=bp/d:bp/d:d*length(x)*(bp/d);
subplot(2,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('transmitting information as digital signal');


%XXXXXXXXXXXXXXXXXXXXXXX Modulation XXXXXXXXXXXXXXXXXXXXXXXXXXX%
A=2;                                   % Amplitude of carrier signal 
br=1/bp;                               % bit rate
f=br*3;                                 % carrier frequency 
t2=bp/(d-1):bp/(d-1):bp;                 
ss=length(t2);
m=[];

for (i=1:1:length(x))
    if (x(i)==1)
        y=A*cos(2*pi*f*t2);
        y=A*cos(2*pi*f*t2);
    else
        y=0*A*cos(2*pi*f*t2+pi);   
    end
    m=[m y];
end
t3=bp/(d-1):bp/(d-1):bp*length(x);
subplot(2,1,2);
plot(t3,m);
xlabel('time(sec)');
ylabel('amplitude(volt)');
title('waveform for binary PSK modulation coresponding binary information');

Leave a Reply

Your email address will not be published. Required fields are marked *