0% found this document useful (0 votes)
12 views10 pages

Exp2 Template1312

The document outlines the generation of various discrete-time signals including impulse, unit step, ramp, parabolic, sinusoidal, signum, triangular, exponential, rectangular pulse, and random signals. Each signal is plotted using MATLAB with appropriate titles, labels, and grid settings. Additionally, two tasks are included that involve plotting custom random signals based on specified conditions.

Uploaded by

sritejreddy9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views10 pages

Exp2 Template1312

The document outlines the generation of various discrete-time signals including impulse, unit step, ramp, parabolic, sinusoidal, signum, triangular, exponential, rectangular pulse, and random signals. Each signal is plotted using MATLAB with appropriate titles, labels, and grid settings. Additionally, two tasks are included that involve plotting custom random signals based on specified conditions.

Uploaded by

sritejreddy9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

EXP NO: 2 Generation of DT Signals Date:

clc; clear; close all;


n = -10:1:10;
N=length(n);

Impulse Signal

delta = (n == 0);
figure;
stem(n,delta);
title('Impulse Signal \ delta[n]');
xlabel('Time n'); ylabel('\delta[n]');
grid on;

2. Unit Step Signal

step = (n >= 0);


figure;
stem(n,step);
title('Unit Signal \ Step[n]');

1
xlabel('Time n'); ylabel('\Step[n]');
grid on;

3. Ramp Signal

ramp =n .*(n>=0);
figure;
stem(n,ramp,'g','LineWidth',2);
title('Ramp Signal r[n] = n*u[n]');
xlabel('Time n'); ylabel('r[n]');
grid on;

2
4. Parabolic Signal

parabolic = (n.^2) /2.* (n >=0);


figure;
stem(n,parabolic,'m','LineWidth', 2);
title('Parabolic Signal x[n] = n^2*u[n]');
xlabel('Time n'); ylabel('x[n]');
grid on;

3
5. Sinusoidal Signal

f=1;
x =sin(2*pi*f*n);
stem(n,x ,'b','LineWidth',2);
title('Sinusodal Signal x[n]');
xlabel('Time n');ylabel('x[n]');
grid on;

4
6. Signum Signal

signum=zeros(size(n));
signum(n>0)=1;
signum(n<0)=-1;
stem(n,signum,'cyan','LineWidth',2);
title('Signum Signal sgn[n]');
xlabel('Time n');ylabel('Signum Signal sgn[n]');
grid on;

7. Triangular Signal

triangle = 1 - 2*abs(n)/10;
triangle(triangle<0)=0;
figure;
stem(n,triangle,'r','LineWidth',2);
title('Triangular Signal');
xlabel('Time n');ylabel('x[n]');
grid on;

5
8. Exponential Signal
exponential = exp(-n).*(n>=0);
figure;
stem(n,exponential,'cyan','LineWidth',2);
title('Exponential Signal x[n]');
xlabel('Time n');ylabel('x[n]');
grid on;

6
9. Rectangular Pulse

rect = (abs(n) <=2);


figure;
stem(n, rect, 'r', 'LineWidth', 2);
title('Rectangular Signal');
xlabel('Time n'); ylabel('x[n]');
grid on;

10. Random Signal;

n=-4:0.01:1;
rand = zeros(size(n));
rand(n>-4 & n<=-2)=n(n>-4 & n<=-2) + 6;
rand(n>=-2 & n<1)=n(n>=-2 & n<1) - 4;
figure;
stem(n,rand,'r','LineWidth',2);
title('Random Signal');
xlabel('Time n');ylabel('x[n]');

7
grid on;

Task 1: plot

n=-4:0.01:5;
rand = zeros(size(n));
rand(n>-4 & n<=-1)=5+n(n>-4 & n<=-1);
rand(n>=-1 & n<3)=-2 + n(n>=-1 & n<3);
rand(n>=2 & n<5)=5*n(n>=2 & n<5);
figure;
stem(n,rand,'r','LineWidth',2);
title('Task 1');
xlabel('Time n');ylabel('x[n]');
grid on;

8
Task 2: plot

n=-2:0.01:2;
rand = zeros(size(n));
rand(n>=-2 & n<2)=5*n(n>=-2 & n<2);
rand(n>=2 & n<=5)=2* (n(n>=2 & n<3)^2)-n(n>=2 & n<3);
figure;
stem(n,rand,'r','LineWidth',2);
title('Task 2');
xlabel('Time n');ylabel('x[n]');
grid on;

9
Registration Number:
Name of the Student:
Submission Mark (Out of 10):

10

You might also like