Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

UEC2412 DIGITAL SIGNAL PROCESSING LABORATORY

Date: 20.03.2023 Register no: 3122 21 3002 110


Exp No: 1

GENERATING BASIC ELEMENTARY AND RANDOM SIGNALS

Aim:
To generate basic elementary and random signals using MATLAB.
1. Unit Impulse Signal
2. Unit Step Signal
3. Ramp Signal
4. Exponential Signal
5. Sinusoidal Signal
6. Cosine Wave
7. Sinc Signal
8. Rectangular Pulse
9. Triangular Pulse
10. Random Signal

Software used:
MATLAB (R2022-b)\

Description:
Elementary signals are those that are basically used to analyze basic systems. impulse
signal, unit step signal, sinusoidal signal, exponential signal, and ramp signal are some of the
elementary signals. Random signals are those which are not precisely predictable; that is, given
the past history of a signal and the amplitude values it has taken on, it is not possible to precisely
predict what particular value it will take on at certain instants in the future. The value of the
signal may only be predicted subject to certain probabilities.

1
Code:
clc;clear all;close all;

%1. Unit Impulse signal


n=-5:5; x1=(n==0); subplot(5,3,1);
stem(n,x1,'r','Linewidth',1); ylabel('Amplitude'); xlabel('Time');
title('1.Unit impulse Signal');

%2. Unit Step Signal


n=-5:5; x2=(n>=0); subplot(5,3,2);
stem(n,x2,'g','Linewidth',1); ylabel('Amplitude'); xlabel('Time')
title('2.Unit step Signal')

%3. Ramp signal


n=-5:5; x3=n.*(n>=0); subplot(5,3,3);
stem(n,x3,'Linewidth',1); ylabel('Amplitude'); xlabel('Time'); title('3.Ramp Signal')

%4. Exponential Signal

%4.1 Real Exponential Signal


n=-5:0.1:5; a=-1; y=exp(a.*n);
subplot(5,3,4); stem(n,y,'r'); ylabel('Amplitude'); xlabel('Time');
title('4.1.Real exponential Signal');

%4.2 Complex exponential Signal


n=-5:0.1:5; y1=exp((2+3j).*n); subplot(5,3,5); stem(n,y1,'*c','LineWidth',1);
ylabel('Amplitude'); xlabel('Time');
title('4.2.Complex exponential Signal');

%5. Sinusoidal Signal


f=1000; fs=10*f; n=0:1/fs:20/fs;
x4=sin(2*pi*f*n); subplot(5,3,7); stem(n,x4,'x','Linewidth',1) ylabel('Amplitude');
xlabel('Time') title('5.Sine Signal')

%6. Cosine Signal


f=1000; fs=10*f; n=0:1/fs:20/fs;
x6=cos(2*pi*f*n); subplot(5,3,8); stem(n,x6,'Linewidth',1); ylabel('Amplitude');
xlabel('Time') title('6.Cosine Signal')
clc;

%7. Sinc Signal


n1=linspace(-5,5); x5=sinc(n1); subplot(5,3,9); stem(n1,x5,'y'); ylabel('Amplitude');
xlabel('Time'); title('7.Sinc Signal');

2
%8. Rectangular Pulse
n=-5:5; y2=(n>=-2); y4=(n<=2); y5=y2&y4; subplot(5,3,10);
stem(n,y5,'.m','LineWidth',1); ylabel('Amplitude'); xlabel('Time'); title('8.Rectangular
pulse');

%9. Triangular Pulse


n=-5:5; y3=5-abs(n);
subplot(5,3,11); stem(n,y3,'.b'); axis([-10 10 0 5 ]); ylabel('Amplitude'); xlabel('Time');
title('9.Triangular pulse');

%10.Random Signals

%10.1 Uniform Random Variable Function


a=0.5; b=0.5;
x=a+(b-a)*rand(1,10); subplot(5,3,13); histogram(x); xlabel('time'); ylabel('Amplitude')
title('Uniform Random Variable function')

%10.2 Gaussian Variable Function


N=10^8; mu=3; s=3; rand(1,N); rand(0,1);
x=sqrt(s)*randn(1,N)+mu; subplot(5,3,14); histogram(x);
xlabel('time'); ylabel('Amplitude'); title('Gaussian Variable function')

Simulated Graph:

Result
The basic elementary and random signals have been plotted using MATLAB and has been
analyzed accordingly

You might also like