0% found this document useful (0 votes)
56 views4 pages

Experiment I Digital Communication

The document describes an experiment to generate a pulse amplitude modulated wave. It generates rectangular pulses and examines their frequency spectrum. It then generates a test signal, samples it with the rectangular pulses, and recovers the test signal after low pass filtering and maximum detection. Frequency spectra are examined at each step of the process.

Uploaded by

Abhay Setia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views4 pages

Experiment I Digital Communication

The document describes an experiment to generate a pulse amplitude modulated wave. It generates rectangular pulses and examines their frequency spectrum. It then generates a test signal, samples it with the rectangular pulses, and recovers the test signal after low pass filtering and maximum detection. Frequency spectra are examined at each step of the process.

Uploaded by

Abhay Setia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Experiment I

Aim: To generate Pulse Amplitude Modulated Wave

MATLAB CODE:

df = 0.1;
T = 10*10^(-3);
ts = 1/10000;
fs = 1/ts;
tn = 0:ts:T;
N = size(tn);
s = zeros(N);
s(1:50) = ones(size(s(1:50)));
figure(1);
subplot(2,1,1);
plot(tn,s,'k');
xlabel('Time in seconds');
ylabel('Amplitude');
title('Rectangular Pulse');
ylim([0 1.2]);
xlim([0 0.015]);

K = 256;
s1 = abs(fft(s,K));
s1 = fftshift(s1);
f = (-K/2:K/2-1)/K;
subplot(2,1,2);
plot(100*f,s1,'k');
grid on;
xlabel('frequency');
ylabel('Amplitude');
title('Spectrum of Rectangular Pulses');

ts = 1/fs;
df = 0.1;
tn = 0:ts:0.6;
x = 1 + (1/3)*(sin(2*pi*5*tn) + sin(2*pi*10*tn) + sin(2*pi*15*tn));
figure(2);
subplot(2,1,1)
plot(tn,x,'k');
grid on;
xlabel('time');
ylabel('Amplitude');
title('Original Signal');

[X,x1,df] = fftseq(x,ts,df);
X=X/fs;
n=length(fftshift(abs(X)));
f = fs*(-n/2:n/2-1)/n;
subplot(2,1,2)
plot(f,fftshift(abs(X)),'k');
grid on;
xlabel('Frequency');
ylabel('Amplitude');
title('Frequency Spectrum of Original Signal');
xlim([-20 20]);

N = length(tn);
s(1:N)=0;
n=0;
for i=1:60:N-1
s(i+n:i+n+30) = 1;
n = n+1;
end
figure(3);
subplot(2,1,1)
plot(tn,s(1:length(tn)),'k');
ylim([0 1.2]);
grid on;
xlabel('Time');
ylabel('Amplitude');
title('Sampling Pulse Sequence (100 pulses)');

y = x.*s(1:length(tn));
subplot(2,1,2)
plot(tn,y,'k');
grid on;
xlabel('Time');
ylabel('Amplitude');
title('Sampled Analog Signal');

[X,x1,df] = fftseq(y,ts,df);
X=X/fs;
n=length(fftshift(abs(X)));
f=fs*(-n/2:n/2-1)/n;
figure(4);
subplot(2,1,1)
plot(f,fftshift(abs(X)),'k');
grid on;
xlabel('Frequency');
ylabel('Amplitude')
title('Spectrum of Sampled Signal');
xlim([-20 20]);

y1 = lowpass(y,0.1,50);
subplot(2,1,2)
plot(y1,'k');
grid on;
xlabel('Frequency');
ylabel('Amplitude');
title('Low Pass filtered output of Sampled Signal');

N=length(y1);
for i=1:N-1
if y1(i)<=0
y1(i)=0;
end
end
n=1;
yi(1) = y1(1);
for i=15:60:N-1
n=n+1;
yi(n)=max(y1(i-14:i+15));
end
t=0:n-1;
t=t*0.006;
figure(5);
subplot(2,1,1)
plot(t,yi,'k');
grid on;
xlabel('Time');
ylabel('Amplitude');
title('Recovered Signal');

[X,x1,df] = fftseq(yi,ts/60/df);
fs=fs/60;
X=X/fs;
n=length(fftshift(abs(X)));
f=fs*(-n/2:n/2-1)/n;
subplot(2,1,2)
plot(f,fftshift(abs(X)),'k');
grid on;
xlabel('Frequency');
ylabel('Amplitude');
title('Spectrum of Recovered Signal');
xlim([-20 20]);

function [M,m,df] = fftseq(m,ts,df)


fs = 1/ts;
if nargin == 2
n1 = 0;
else
n1=fs/df;
end
n2 = length(m);
n=2^(max(nextpow2(n1),nextpow2(n2)));
M=fft(m,n);
m=[m,zeros(1,n-n2)];
df = fs/n;

Observations:

You might also like