0% found this document useful (0 votes)
20 views8 pages

PCM & Sampling, FSK, PSK

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)
20 views8 pages

PCM & Sampling, FSK, PSK

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/ 8

Pulse code modulation

clc;
clear all;
close all;
n=input('enter n value for n bit pcm system:');
n1=input('enter number of samples in a period:');
L=2^n;
x=0:2*pi/n1:4*pi;
s=8*sin(x);
subplot(3,2,1)
plot(s);
title('analog signal');
ylabel('amplitude');
xlabel('time');
subplot(3,2,2)
stem(s);
grid on;
title('sampled signal');
ylabel('amplitude');
xlabel('time');
%quantization process
vmax=8;
vmin=-vmax;
del=(vmax-vmin)/L;
part=vmin:del:vmax;
code=vmin-(del/2):del:vmax+(del/2);
[ind,q]=quantiz(s,part,code);
L1=length(ind);
L2=length(q);
for i=1:L1
if(ind(i)~=0)
ind(i)=ind(i)-1;
q(i)=vmin+(del/2);
end
end
subplot(3,2,3)
stem(q);
grid on;
title('quantized signal');
ylabel('amplitude');
xlabel('time');
%encoding process figure
code=de2bi(ind,'left-msb');
k=1;
for i=1:L1
for j=1:n
coded(k)=code(i,j);
j=j+1;
k=k+1;
end
i=i+1;
end
subplot(3,2,4);
grid on;
stairs(coded);
axis([0 100 -2 3]);
title('encoded signal');
ylabel('amplitude');
xlabel('time');
%demodulation of pcm signal
qunt=reshape(coded,n,length(coded)/n);
index=bi2de(qunt','left-msb');
q=del*index+vmin+(del/2);
subplot(3,2,5);
grid on;
plot(q);
title('demodulated signal');
ylabel('amplitude');
xlabel('time');

enter n value for n bit pcm system:2

enter number of samples in a period:10


Sampling

%sampling theorem%
clc;clear all; close all;
t=0:0.001:1;
f=8;
x=cos(2*pi*f*t);
plot(t,x);title('Original Signal');
%when fs>2fm%
fs1=8*f;
ts1=1/fs1;
n1=0:ts1:1;
xs1=cos(2*pi*f*n1);
figure;
plot(n1,xs1,'r');title('Over sampled signal');
hold on;
plot(t,x);
hold off;
%when fs=2fm%
fs2=2*f;
ts2=1/fs2;
n2=0:ts2:1;
xs2=cos(2*pi*f*n2);
figure;
plot(n2,xs2,'r');title('Critical sampled signal');
hold on;
plot(t,x);
hold off;
%when fs<2fm%
fs3=1.7*f;
ts3=1/fs3;
n3=0:ts3:1;
xs3=cos(2*pi*f*n3);
figure;
plot(n3,xs3,'r');title('Under sampled signal');
hold on;
plot(t,x);
hold off;

Frequency shift keying

clc;
clear all;
close all;
fc1=input('enter the freq of 1st sine wave carrier:');
fc2=input('enter the freq of 2nd sine wave carrier:');
fp=input('enter the freq of period binary pulse(message):');
amp=input('enter the amplitude(for both carrier & binary pulse message):');
amp=amp/2;
t=0:0.001:1;
c1=amp.*sin(2*pi*fc1*t);
c2=amp.*sin(2*pi*fc2*t);
subplot(4,1,1);
plot(t,c1)
xlabel('time')
ylabel('amplitude')
title('carrier 1 wave')
subplot(4,1,2)
plot(t,c2)
xlabel('time')
ylabel('amplitude')
title('carrier 2 wave')
m=amp.*square(2*pi*fp*t)+amp
subplot(4,1,3)
plot(t,m)
xlabel('time');
ylabel('amplitude');
title('binary message pulses')
for i=0:1000
if m(i+1)==0
mm(i+1)=c2(i+1);
else
mm(i+1)=c1(i+1);
end
end
subplot(4,1,4)
plot(t,mm)
xlabel('time')
ylabel('amplitude')
title('modulated wave')

output :

enter the freq of 1st sine wave carrier:50

enter the freq of 2nd sine wave carrier:20

enter the freq of period binary pulse(message):5

enter the amplitude(for both carrier & binary pulse message):2


PHASE SHIFT KEYING

clc;
clear all;
close all;
fc1=input('enter the freq of 1st sine wave carrier:');
fc2=input('enter the freq of 2nd sine wave carrier:');
fp=input('enter the freq of periodic binary pulse (message)');
amp=input('enter the amplitude (for both carrier & binary pulse messsage):');
amp=amp/2;
t=0:0.001:1;
c1=amp.*sin(2*pi*fc1*t);
c2=amp.*sin(2*pi*fc2*t+pi);
subplot(4,1,1);
plot(t,c1)
xlabel('time')
ylabel('amplitude')
title('carrier 1 wave')
subplot(4,1,2)
plot(t,c2)
xlabel('time')
ylabel('amplitude')
title('carrier 2 wave')
m=amp.*square(2*pi*fp*t)+amp;
subplot(4,1,3);
plot(t,m)
xlabel('time')
ylabel('amplitude')
title('binary message pulses')
for i=0:1000
if m(i+1)==0
mm(i+1)=c2(i+1);
else
mm(i+1)=c1(i+1);
end
end
subplot(4,1,4)
plot(t,mm)
xlabel('time')
ylabel('amplitude')
title('modulated wave')

OUTPUT:

enter the freq of 1st sine wave carrier:20

enter the freq of 2nd sine wave carrier:50


enter the freq of period binary pulse(message):5

enter the amplitude(for both carrier & binary pulse message):2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy