Matlab code for Pulse Code modulation
Pulse-code modulation (PCM) is a method used to digitally represent sampled analog signals. It is the standard form
of digital audio in computers, Compact Discs, digital telephony and other
digital audio applications. In a PCM stream, the amplitude of the analog signal
is sampled regularly at uniform intervals, and each sample is quantized to the
nearest value within a range of digital steps.
PCM streams have two basic
properties that determine their fidelity to the original analog signal: the
sampling rate, the number of times per second that
samples are taken; and the bit depth, which determines the number of possible
digital values that each sample can take.
Pulse
width modulation
Pulse
position modulation
% Program for Pulse Code modulation
with input signal x = [.2 .5 .3 .6]
clc
disp('select your choice 1 - pulse width 2 - pulse position')
i = input('select your choice - : ')
if i == 1
x = input('input signal = ')
[y,t ] = modulate(x,100,1000,'pwm','centered');
subplot(2,1,1)
plot(x)
title('Input signal')
subplot(2,1,2);
plot(t,y)
title('Pulse Width Modulation')
end
if i == 2
x = input('input signal = ')
[y,t ]= modulate(x,100,1000,'ppm',0.2);
subplot(2,1,1)
plot(x)
title('Input signal')
subplot(2,1,2);
plot(t,y)
title('Pulse Position Modulation')
end
clc
disp('select your choice 1 - pulse width 2 - pulse position')
i = input('select your choice - : ')
if i == 1
x = input('input signal = ')
[y,t ] = modulate(x,100,1000,'pwm','centered');
subplot(2,1,1)
plot(x)
title('Input signal')
subplot(2,1,2);
plot(t,y)
title('Pulse Width Modulation')
end
if i == 2
x = input('input signal = ')
[y,t ]= modulate(x,100,1000,'ppm',0.2);
subplot(2,1,1)
plot(x)
title('Input signal')
subplot(2,1,2);
plot(t,y)
title('Pulse Position Modulation')
end
0 comments:
Post a Comment