Ss Lab 2
Ss Lab 2
EQUIPMENT:
DISCUSSION:
INTRODUCTION:
Analog Signal Processing deals with the processing of continuous time signals whereas in
Digital Signal Processing we study discrete-time discrete-valued signals processed by
digital computers or other data processing machines. First step in going from analog to
digital is ‘sampling’. It is the reduction of a continuous signal to a discrete signal. A
common example is the conversion of a sound wave (a continuous-time signal) to a
sequence of samples (a discrete-time signal). If the amplitude of a DT signal is also made
discrete through the process of ‘quantization’ or rounding off, then it becomes a Digital
Signal.
In this lab, we will learn to generate unit sample, unit step and sinusoidal signals using
MATLAB.
Impulse:
the simplest signal is the unit impulse signal which is as δ (n) =
as δ (n) = 1 for n = 0
= 0 for n ≠ 0
Unit Step:
the general form of step function is
u (n) = 1 for n ≥ 0
= 0 for n< 0.
Sinusoid:
x(n) Asin(n )
where, 2f
n = integer variable called the sample number,
A = amplitude of the sinusoid,
= frequency in radians per sample,
= phase in radians.
Exponential:
The decaying exponential is a basic signal in DSP. Their general form is given by x (n) = an for
all n
Ramp
The signal is given by u (n) = n for n ≥ 0
LAB TASK:
Generation of Unit Impulse (n) :
Consider the following code:
n=-1:10;
s=[0 1
zeros(1,10)];
stem(n,s);
xlabel('n');
ylabel('Amplitude');
title('unit sample
sequence'); axis([-10 20 0
1]);
OR
%% Generation of a Unit Impulse
n=-2:10; %Generate the sample index vector
imp=n==0; %Set the sample at zero index equal
to 1 stem(n,imp); %Plot the impulse signal
xlabel('Samples'); %Give label to x-axis
ylabel('Amplitude'); %Give label to y-axis
title('Unit Impulse Signal (\delta(n))');
grid; %Show grid in figure
Its output is as follows
c=0:40;
freq=.1;
phase=0;
amp=2;
arg=2*pi*freq*c+phase;
ans=amp*cos(arg);
stem(c,ans);
axis([0 40 -3 3]);
gridon;
title('cosine');
xlabel('time index');
ylabel('amplitude');
Its output is as follow,
3. Write a program to generate a sine wave with any suitable frequency. Your code
should ask for the amplitude of the sine wave as an input from theuser.
(Use ‘input’ function. Please see MATLAB help for syntax)
1. Write a program to generate a sine wave with any suitable frequency. Your code
should ask for the amplitude of the sine wave as an input from the user.
(Use ‘input’ function. Please see MATLAB help for syntax)