Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 15

Experiment 2

Singularity Functions
Program 1 : Generate A unit Delta Function:clc; clear all; close all; d = input('Enter the INDEX for DELTA function: '); n = -d : 1 :d ; delta = [ zeros(1,d) 1 zeros(1,d) ]; subplot(2,1,1); plot(n,delta); axis([-(d+1) (d+1) -0.5 1.5]); title('Cont. Unit Delta Function') xlabel('INDEX'); ylabel('AMPLITUDE'); subplot(2,1,2); stem(n,delta); axis([-(d+1) (d+1) -0.5 1.5]); title('Discrete Unit Delta Function') xlabel('INDEX'); ylabel('AMPLITUDE');

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

Singularity Functions
Output:
Enter the INDEX for DELTA function: 5

Cont. Unit Delta Function 1.5 AMPLITUDE 1 0.5 0 -0.5 -6

-4

0 2 INDEX Discrete Unit Delta Function

-2

1.5 AMPLITUDE 1 0.5 0 -0.5 -6

-4

-2

0 INDEX

Program 2 : Generate A Unit Step Function:-

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

clc; clear all; close all; d

Singularity Functions

= input('Enter the INDEX for Unit Step function: ');

n = -d : 1 :d ; for i = 1 : 1 : 2*d +1 if (i<=d) unit_step(i)=0; else unit_step (i)=1; end end subplot(2,1,1); plot(n, unit_step); axis([-(d+1) (d+1) -0.5 1.5]); title(' Cont. Unit Step Function') xlabel('INDEX'); ylabel('AMPLITUDE'); subplot(2,1,2); stem(n, unit_step); axis([-(d+1) (d+1) -0.5 1.5]); title(' Discrete Unit Step Function') xlabel('INDEX'); ylabel('AMPLITUDE');

Output :

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

Enter the INDEX for Unit Step function: 5

Singularity Functions

Cont. Unit Step Function 1.5 AMPLITUDE 1 0.5 0 -0.5 -6

-4

-2

0 2 INDEX Discrete Unit Step Function

1.5 AMPLITUDE 1 0.5 0 -0.5 -6

-4

-2

0 INDEX

Program 3 : Generate A Ramp Function:-

clc; clear all; close all;

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

d = input('Enter the INDEX for Ramp function: '); n = -d : 1 :d ;

Singularity Functions

for i = 1 : 1 : 2*d +1 if (i<=d) ramp(i)=0; else ramp (i)=i-(d+1); end end subplot(2,1,1); plot(n,ramp); axis([-(d+1) (d+1) -1 (d+1)]); title('Cont. Ramp Function') xlabel('INDEX'); ylabel('AMPLITUDE'); subplot(2,1,2); stem(n,ramp); axis([-(d+1) (d+1) -0.5 (d+1)]); title('Discrete Ramp Function') xlabel('INDEX'); ylabel('AMPLITUDE');

Output:
Enter the INDEX for Ramp function: 5

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

Singularity Functions
Cont. Ramp Function 6 AMPLITUDE 4 2 0 -6 -4 -2 0 2 INDEX Discrete Ramp Function 4 6

6 AMPLITUDE 4 2 0 -6 -4 -2 0 INDEX 2 4 6

Program 4 : Generate A Shifted Unit Delta Function :clc; clear all; close all; d = input('Enter the INDEX Range for DELTA function: '); k = input('Enter the value for Delay/Advancing the function:')' n = -d : 1 :d ;

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

for i = 1 : 1 : 2*d +1 if (i == d+k+1 ) delta(i)=1; else delta (i)=0; end end

Singularity Functions

subplot(2,1,1); plot(n,delta); axis([-(d+1) (d+1) -0.5 1.5]); title('Shifted Cont. Unit Delta Function') xlabel('INDEX'); ylabel('AMPLITUDE'); subplot(2,1,2); stem(n,delta); axis([-(d+1) (d+1) -0.5 1.5]); title('Shifted Discrete Unit Delta Function') xlabel('INDEX'); ylabel('AMPLITUDE');

Output: 1. Enter the INDEX Range for DELTA function: 12


Enter the value for Delay/Advancing the function:6 k =5 5

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

Singularity Functions
Shifted Cont. Unit Delta Function 1.5 AMPLITUDE 1 0.5 0 -0.5

-10

0 5 INDEX Shifted Discrete Unit Delta Function

-5

10

1.5 AMPLITUDE 1 0.5 0 -0.5

-10

-5

0 INDEX

10

2. Enter the INDEX Range for DELTA function: 15


Enter the value for Delay/Advancing the function:-5 k= -5

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

Singularity Functions
Shifted Cont. Unit Delta Function 1.5 AMPLITUDE 1 0.5 0 -0.5

-10

0 5 INDEX Shifted Discrete Unit Delta Function

-5

10

1.5 AMPLITUDE 1 0.5 0 -0.5

-10

-5

0 INDEX

10

Program 5 : Generate A Shifted Unit Step Function :clc; clear all; close all; d = input('Enter the INDEX Range for Unit Step function: '); k = input('Enter the value for Delay/Advancing the function:')' n = -d : 1 :d ;

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

for i = 1 : 1 : 2*d +1 if (i<=d+k) unit_step(i)=0; else unit_step (i)=1; end end

Singularity Functions

subplot(2,1,1); plot(n, unit_step); axis([-(d+1) (d+1) -0.5 1.5]); title(' Shifted Cont. Unit Step Function') xlabel('INDEX'); ylabel('AMPLITUDE'); subplot(2,1,2); stem(n, unit_step); axis([-(d+1) (d+1) -0.5 1.5]); title(' Shifted Discrete Unit Step Function') xlabel('INDEX'); ylabel('AMPLITUDE');

Output: 1. Enter the INDEX Range for Unit Step function: 15


Enter the value for Delay/Advancing the function:5 k= 5

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

Singularity Functions

Shifted Cont. Unit Step Function 1.5

1 AMPLITUDE

0.5

-0.5

-15

-10

-5

0 INDEX

10

15

Shifted Discrete Unit Step Function 1.5

1 AMPLITUDE

0.5

-0.5

-15

-10

-5

0 INDEX

10

15

2. Enter the INDEX Range for Unit Step function: 15


Enter the value for Delay/Advancing the function:-5 k= -5

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

Singularity Functions
Shifted Cont. Unit Step Function 1.5 AMPLITUDE 1 0.5 0 -0.5

-15

-10

0 5 INDEX Shifted Discrete Unit Step Function

-5

10

15

1.5 AMPLITUDE 1 0.5 0 -0.5

-15

-10

-5

0 INDEX

10

15

Program 6 : Generate A Shifted Ramp Function :clc; clear all; close all; d = input('Enter the INDEX Range for RAMP function: '); k = input('Enter the value for Delay/Advancing the function:') n = -d : 1 :d ; for i = 1 : 1 : 2*d +1 if (i<=d+k+1)

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

delta(i)=0; Singularity else delta(i)=i-(d+k+1); end end subplot(2,1,1); plot(n,delta); axis([-(d+1) (d+1) -1 (d+1)]); title('Shifted Cont. Ramp Function') xlabel('INDEX'); ylabel('AMPLITUDE'); subplot(2,1,2); stem(n,delta); axis([-(d+1) (d+1) -0.5 (d+1)]); title('Shifted Discrete Ramp Function') xlabel('INDEX'); ylabel('AMPLITUDE');

Functions

Output: 1. Enter the INDEX Range for RAMP function: 15


Enter the value for Delay/Advancing the function:5 k= 5

REMAINING

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

Singularity Functions
Shifted Cont. Ramp Function 15 AMPLITUDE 10 5 0 -15 -10 0 5 INDEX Shifted Discrete Ramp Function -5 10 15

15 AMPLITUDE 10 5 0 -15 -10 -5 0 INDEX 5 10 15

2. Enter the INDEX Range for Unit Step function: 15


Enter the value for Delay/Advancing the function:-5 k= -5

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

Experiment 2

Singularity Functions
Shifted Cont. Ramp Function 15 AMPLITUDE 10 5 0 -15 -10 0 5 INDEX Shifted Discrete Ramp Function -5 10 15

15 AMPLITUDE 10 5 0 -15 -10 -5 0 INDEX 5 10 15

DIGITAL SIGNAL PROCESSING 7 SEMESTER ELECTRONICS & COMMUNICATION DIVISION : CX/C3 ROLL NO. :- 65 ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE, RAJKOT.
TH

You might also like