Experiment-1 (1)
Experiment-1 (1)
Basics of Digital Signal and operations, Sampling Theorem and its effect:
MATLAB
Aim: To generate the basic discrete time signal and understand the sampling theorem
1.1. Generation of Continuous time signal and Discrete time signal
%%%%% Generation of analog sinusoidal signals %%%%%%%%%%%
clear all
clc
freq1 = 100; % frequency 1
freq2 = 600; % frequency 2
mag = 2; % magnitude
figure(3)
subplot(2,1,1);
plot(t, y,'r.-');
title('CT signal y');
xlabel('time(sec)');ylabel('Amplitude');
subplot(2,1,2);
stem(n,y2,'rx');
Output Plots:
2
(Need to write 1 or 2 sentence about the observation made out of the plot for
each simulation plots)
1.2 Elementary Discrete time signal generation
%%%%% Generation of elementary DT signals %%%%%%%%%%%
close all
clear all
clc
%%%%% Code to generate the Unit step sequence %%%%%%
3
Output Plots:
1.3 Linear Convolution
(A) MATLAB Code to compute the linear convolution of two
signals
close all
clear all
clc
x=input('Enter x: ')
h=input('Enter h: ')
m=length(x);
n=length(h);
X=[x,zeros(1,n)];
H=[h,zeros(1,m)];
for i=1:n+m-1
Y(i)=0;
for j=1:i
Y(i)=Y(i)+X(j)*H(i-j+1);
end
end
Y
stem(Y); ylabel('Y[n]'); xlabel(' Samples (n)');
title('Convolution of Two Signals without using Inbuilt conv function');
Output Plot:
(B) Verify user answer with the MATLAB Inbuilt function: conv
4
1.4 Shannon- Nyquist Sampling Theorem
clear all;close all;clc;
% signal parameters
T=0.001; %%%%% time step
t=0:10^(-5):T; %Time increment makes smooth signal ( You can verify 10^-3 or 10^-2
to see the non-smooth effect)
f1=1000; %Signal 1 frequency=1kHz
f2=1900; %Signal 2 frequency=1.9kHz
%Generate the original Continuous time signal ;
x=cos(2*pi*t*f1)+cos(2*pi*t*f2); % CT signal
subplot(2,2,1);
plot(t,x);grid on;
title('Continuous time signal');
xlabel('t');
ylabel('x(t)');
% Maximum frequency component of the signal
fmax=max(f1,f2);
%keyboard
% Plot the "analog" signals
subplot(2,1,1);
plot(t, x,'r.-', t, y,'b-');
my_title = sprintf('Simulated analog signals x= dots, y=solid');
title(my_title);
xlabel('time');ylabel('Amplitude');
% Plot the "sampled" signals
subplot(2,1,2);
%plot(n,x2,'rx', n,y2,'bo')
stem(n,x2,'rx'); hold on
stem(n,y2,'bo')
my_title = sprintf('Simulated digital signals x=x, y=o');
title(my_title);
xlabel('samples');
ylabel('Amplitude');
Output Plots:
Observe the DT signal for different sampling frequencies: 100, 500,1000, 1200,
1800
Conclusion: