0% found this document useful (0 votes)
59 views2 pages

All All: For If

This document contains Matlab code to simulate amplitude shift keying (ASK) modulation and demodulation. It generates a carrier signal, randomly generates 1s and -1s as message bits, modulates the carrier by multiplying with the message bits, and demodulates by correlating the received signal with the carrier to recover the original bits. The code produces 4 subplots showing the carrier signal, a sample message signal, the modulated signal, and the demodulated bits.

Uploaded by

Radha Nandhini
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views2 pages

All All: For If

This document contains Matlab code to simulate amplitude shift keying (ASK) modulation and demodulation. It generates a carrier signal, randomly generates 1s and -1s as message bits, modulates the carrier by multiplying with the message bits, and demodulates by correlating the received signal with the carrier to recover the original bits. The code produces 4 subplots showing the carrier signal, a sample message signal, the modulated signal, and the demodulated bits.

Uploaded by

Radha Nandhini
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

carrier signal

2
0
-2

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

message signal
amplitude

1
0
-1

time in sec
modulated signal
amplitude

2
0
-2

4
time in sec

1
0.5
0

clc;
clear all;
close all;
Tb=1;
N=8;
m=rand(1,N);
t=0:Tb/100:1;
A=2;f=10;
c=A*sin(2*pi*f*t);
subplot(4,1,1);
plot(t,c);
title('carrier signal');
t1=0;
t2=Tb;
for i=1:N;
T=t1:0.01:t2
if m(i)>0.5;
m(i)=1;
msg=ones(1,length(T));
else
m(i)=-1;
msg=-1*ones(1,length(T));
end
d(i,:)=msg;
ask_sig(i,:)=d(i,:).*c
t1=t1+(Tb+0.01);
t2=t2+(Tb+0.01);

subplot(4,1,2);
plot(T,d(i,:));
title('message signal');
xlabel('time in sec');
ylabel('amplitude');
hold on
subplot(4,1,3);
plot(T,ask_sig(i,:));
title('modulated signal');
xlabel('time in sec');
ylabel('amplitude');
hold on
end
hold off;
t1=0;t2=Tb;
for i=1:N;
x=sum(ask_sig(i,:).*c);
%decision
if x>0
demod(i)=1;
else
demod(i)=0;
end
t1=t1+(Tb+0.01);
t2=t2+(Tb+0.01);
end
subplot(4,1,4);
stem(demod);

You might also like