Differential Pulse Code Modulation DPCM Explained using MATLAB | ADC 4.13

Описание к видео Differential Pulse Code Modulation DPCM Explained using MATLAB | ADC 4.13

Differential Pulse Code Modulation DPCM explained and a how to do dpcm using MATLAB (code in description) simulation is the content of this video. DPCM is basically a signal encoder which uses the baseline of pulse code modulation PCM but adds some functionalities based on the prediction of the samples of the signal.

% DPCM implementation by Ahmad Kamal Hassan

clear all; close all; clc

rng(1,'twister') % For reproducibility

k = 0:1:10; %Time Index

x_k = [randn(1,11)]; %Random Numbers

figure(1)
stem(k,x_k,'r')
xlabel('time index [k]'); ylabel('Amplitude')
keyboard

%%%%%%Transmitter Side

x_kdelay = [0 x_k(1:end-1)]; %Delay by 1 unit

d_k = x_k - x_kdelay;

figure(2)
stem(k,d_k, 'b')
xlabel('time index [k]'); ylabel('Amplitude')
hold on

keyboard
%Quantization Level L = 2^n, n=2
dq_tx = [];
for i1 = 1:11
if (d_k(i1) %=1) % Correct the greater than sign
dqe = 1.5;
elseif (d_k(i1) %=0) % Correct the greater than sign
dqe = 0.5;
elseif (d_k(i1) %=-1) % Correct the greater than sign
dqe = -0.5;
else (d_k(i1) %-1); % Correct the greater than sign
dqe = -1.5;
end

dq_tx = [dq_tx dqe];
end

stem(k,dq_tx,'g')
keyboard


%%%%%%Reciver
pred = 0;
x_hat = [];

for i2 = 1:11

x_ind = pred +dq_tx(i2);

x_hat = [x_hat x_ind];
pred = x_ind;

end
figure (3)
stem(k,x_k,'r')
hold on
stem(k,x_hat, 'm')
xlabel('time index [k]'); ylabel('Amplitude')
keyboard

% Quantization Noise
q_n = x_k - x_hat;

figure(4)
plot(k,q_n)
xlabel('time index [k]'); ylabel('Quantization Error')

Комментарии

Информация по комментариям в разработке