0% found this document useful (0 votes)
4 views6 pages

Sampling Theorem and Delta Modulation

Uploaded by

akhilbhosale3
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)
4 views6 pages

Sampling Theorem and Delta Modulation

Uploaded by

akhilbhosale3
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

Sampling Theorem

t=-10:.01:10;
T=4;
fm=1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x);
xlabel('time');ylabel('x(t)')
title('continous time signal')
grid;
n1=-4:1:4
fs1=1.6*fm;
fs2=2*fm;
fs3=8*fm;
x1=cos(2*pi*fm/fs1*n1);
subplot(2,2,2);
stem(n1,x1);
xlabel('time');ylabel('x(n)')
title('discrete time signal with fs<2fm')
hold on
subplot(2,2,2);
plot(n1,x1)
grid;
n2=-5:1:5;
x2=cos(2*pi*fm/fs2*n2);
subplot(2,2,3);
stem(n2,x2);
xlabel('time');ylabel('x(n)')
title('discrete time signal with fs=2fm')
hold on
subplot(2,2,3);
plot(n2,x2)
grid;
n3=-20:1:20;
x3=cos(2*pi*fm/fs3*n3);
subplot(2,2,4);
stem(n3,x3);
xlabel('time');ylabel('x(n)')
title('discrete time signal with fs>2fm')
hold on
subplot(2,2,4);
plot(n3,x3)
grid;
Output Sampling Theorem
Delta Modulation
clc;
clear all;
close all;

fs = 10000;
fm = 100;
t = 0:1/fs:100/fs; % Time Duration
x = 5*sin(2*pi*100*t); % Define Message Signal with peak voltage 5V and
frequency 100Hz

plot(t, x);
hold on

y = [0]; % Output DM signal i.e. stream of 1 or 0


xr = 0; % Output of Integrator i.e. staircase approximation; initial value
= 0
del = 0.4; % Stepsize

for i = 1:length(x)-1
if xr(i) <= x(i) % If current sample greater than the previous values or
output of the integrator, output of DM = 1
d = 1;
xr(i+1) = xr(i) + del; % Staircase approximated value
else
d = 0;
xr(i+1) = xr(i) - del; % If current sample less than the previous values or
output of the integrator, output of DM = 0
end
y = [y d];
end

stairs(t, xr); % Show the staircase approximated signal


title('Staircase Approximated Signal');
hold off

MSE = sum((x - xr).^2) / length(x); % Mean Squared Error (MSE)


disp(['Mean Squared Error (MSE): ', num2str(MSE)]);
Delta Modulation Output
ISI & Noise
% Parameters
N = 1000; % Number of samples
fs = 1000; % Sampling frequency (Hz)
Ts = 1/fs; % Sampling period (s)
t = 0:Ts:(N-1)*Ts; % Time vector

% Generate a binary signal (0 or 1)


data = rand(1, N/10) < 0.5; % 10% of the data is 1, rest is 0
data_signal = zeros(1, N);
for i = 1:length(data)
data_signal(i*10-9:i*10) = data(i);
end

% ISI channel (e.g., a simple delay)


delay = 2; % Delay in samples
channel_response = [1, zeros(1, delay-1), 0.5]; % Impulse response
channel_response = channel_response/sum(channel_response); % Normalize
channel_response_length = length(channel_response);

% Convolve data with the channel response to introduce ISI


noisy_signal = conv(data_signal, channel_response, 'full');
noisy_signal = noisy_signal(1:N);

% Add noise (Gaussian)


snr_db = 10; % Signal-to-noise ratio in dB
snr = 10^(snr_db/10);
noise = awgn(noisy_signal, snr, 'measured'); % Add AWGN

% Plot the signals


figure;
subplot(3,1,1);
plot(t, data_signal, 'b', 'LineWidth', 2);
title('Original Data Signal');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(3,1,2);
plot(t, noisy_signal, 'r', 'LineWidth', 2);
title('Signal with ISI');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(3,1,3);
plot(t, noise, 'g', 'LineWidth', 2);
title('Signal with ISI and Noise');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
ISI & Noise Output

You might also like