0% found this document useful (0 votes)
131 views14 pages

MATLAB Discrete Signal Guide

The document describes generating discrete time signals using MATLAB. It discusses: 1. Writing MATLAB programs to generate unit step, unit ramp, sine, cosine, and exponential signals by plotting them. 2. The programs generate the signals and display them as subplot figures. 3. The aim was to generate and plot various discrete time signals using MATLAB functions.
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)
131 views14 pages

MATLAB Discrete Signal Guide

The document describes generating discrete time signals using MATLAB. It discusses: 1. Writing MATLAB programs to generate unit step, unit ramp, sine, cosine, and exponential signals by plotting them. 2. The programs generate the signals and display them as subplot figures. 3. The aim was to generate and plot various discrete time signals using MATLAB functions.
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/ 14

Ex.

No: 1
Date :02/02/2021
GENERATION OF DISCRETE TIME SIGNALS

AIM:
To generate a discrete time signal sequence (Unit step,
Unit ramp, Sine, Cosine, Exponential, Unit impulse) using
MATLAB function.

APPARATUS REQUIRED:
HARDWARE : Personal

Computer SOFTWARE:

MATLAB

PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.

PROGRAMS: (GENERATION OF BASIC SIGNALS)

%Program for generation of unit


impulse signal
n =-6:1:6;
impulse=[zeros(1,6),ones(1,1),zeros(1,
6)];
subplot(5,2,1);
stem(n,impulse);
title('Impulse Signal');
xlabel('Time Period');
ylabel('Amplitude');
Page no: 1
Siddhesh Gupta C-53 (EN)
%Program for generation of unit step signal
n =-6:1:6;
step=[zeros(1,6),ones(1,7)];
subplot(5,2,2);
stem(n,step);
title('Unit Step Signal');
xlabel('Time Period');
ylabel('Amplitude');
%Program for generation of unit ramp signal
n =-6:1:6;
step=[zeros(1,6),ones(1,7)];
ramp= n.*step;
subplot(5,2,3);
stem(n,ramp);
title('Ramp Signal');
xlabel('Time Period');
ylabel('Amplitude');

%Program for generation of discrete exponential signal:


1) A=2

a=2;
n2=10;
n=0:n2;
exponential1=a.^n;
subplot(5,2,4);
stem(n,exponential1);
title('exponential Signal (a=2)');
xlabel('Time Period');
ylabel('Amplitude');

2) A=-2

a=-2;
n2=10;
n=0:n2;
exponential2=a.^n;
subplot(5,2,5);
stem(n,exponential2);
title('exponential Signal (a=-2)');
xlabel('Time Period');
ylabel('Amplitude');
Page no: 2
Siddhesh Gupta C-53 (EN)
3) A=0.5

a=0.5;
n2=10;
n=0:n2;
exponential3=a.^n;
subplot(5,2,6);
stem(n,exponential3);
title('exponential Signal (a=0.5)');
xlabel('Time Period');
ylabel('Amplitude');

4) A=-0.5

a=-0.5;
n2=10;
n=0:n2;
exponential4=a.^n;
subplot(5,2,7);
stem(n,exponential4);
title('exponential Signal (a=-0.5)');
xlabel('Time Period');
ylabel('Amplitude');

5) A=1

a=1;
n2=10;
n=0:n2;
exponential5=a.^n;
subplot(5,2,8);
stem(n,exponential5);
title('exponential Signal (a=1)');
xlabel('Time Period');
ylabel('Amplitude');

Page no: 3
Siddhesh Gupta C-53 (EN)
%Program for generation of sine
wave
n = [0:0.1:2*pi]
a = sin(n);
subplot(5,2,9);
stem(n,a)
title('Sine Wave Signal');
xlabel('Time Period');
ylabel('Amplitude');
%Program for generation of cosine
wave
n=0:0.01:pi;
a=cos(2*pi*n);
subplot(5,2,10);
stem(n,a);
title('Cosine Wave Signal');
xlabel('Time Period');
ylabel('Amplitude');

Page no: 4
Siddhesh Gupta C-53 (EN)
OUTPUT: (DISCRETE SIGNALS)

Page no: 5
Siddhesh Gupta C-53 (EN)
RESULT:
Thus the MATLAB programs for discrete time signal sequence (Unit
step, Unit ramp, Sine, Cosine, Exponential, Unit impulse) using
MATLAB function written and the results were plotted.

Page no: 6
Siddhesh Gupta C-53 (EN)
Experiment 2 (Different mathematical operations on Discrete Time Signal)
EXP2A 1)

1 clc;

2 n=-5:1:5;
3 y=1.*(n>=0);
4 subplot(3,3,1);
5 stem(n,y);

6 xlabel('n');

7 ylabel('x(n)');

8 title('unit step');

10 %Amplification when A=2

11 y1=2.*(n>=0);
12 subplot(3,3,2);
13 stem(n,y1);
14 xlabel('n');
15 ylabel('2x(n)');
16 title('Amplification a=2');
17
18 %Amplification when A=-2
19 y1=-2.*(n>=0);
20 subplot(3,3,3);
21 stem(n,y1);
22 xlabel('n');
23 ylabel('2x(n)');
24 title('Negative Amplification a=-2');
25
26 %Amplification when A=0.5
27 y1=0.5.*(n>=0);
28 subplot(3,3,4);
29 stem(n,y1);
30 xlabel('n');
31 ylabel('2x(n)');
32 title('Amplification a=0.5');
33
34 %Amplification when A=-0.5
35 y1=-0.5.*(n>=0);
36 subplot(3,3,5);
37 stem(n,y1);
38 xlabel('n');
39 ylabel('2x(n)');
40 title('Negative Amplification a=-0.5');
41
42 %Time Delay
43 n1=n+2;
44 subplot(3,3,6);
45 stem(n1,y);
46 title('delay');
47 xlabel('n');
48 ylabel('X(n+2)');
49
50 %Time Advanced
51 n1=n-2;
52 subplot(3,3,7);
53 stem(n1,y);
54 title('Advanced');
55 xlabel('n');
56 ylabel('X(n-2)');
57
Printed for: [email protected]

Page no:-7
Siddhesh Gupta C-53
EXP2A 2)

1 clc;

2 n=-5:1:5;
3 y=1.*(n>=0);
4 subplot(3,3,1);
5 stem(n,y);

6 xlabel('n');

7 ylabel('x(n)');

8 title('unit step');

10

11 x= [2 3 4 5];

58 y=upsample(x,3);
59 subplot(2,2,1);
60 stem(x);
61 title('Upsampling');
62
63 subplot(2,2,2);
64 stem(y);
65 c=downsample(y,3);
66 subplot(2,2,3);
67 stem(c);
68 title('Downsampling');

Printed for: [email protected]

EXP 2B

1 clc;

2 n=-5:1:5;
3 y=1.*(n>=0);
4 subplot(3,3,1);
5 stem(n,y);

6 xlabel('n');

7 ylabel('x(n)');

8 title('unit step');

10 %Time reversal

69 n2=(-n);
70 subplot(3,3,4);
71 stem(n2,y);
72 title('Time Reversal');
73 xlabel('n');
74 ylabel('X(-n)');
17

18 clc;
19 clear all;
20 close all;
21
22 %two input sequence
23 x=input('enter input sequence')
24 subplot(2,2,1);
Page no:-8
Siddhesh Gupta C-53
25 stem(x);
26 xlabel('n');
27 ylabel('x(n)');
28 title('Input sequence 1');
29
30 y=input('enter input sequence')
31 subplot(2,2,2);
32 stem(y);
33 xlabel('n');
34 ylabel('y(n)');
35 title('Input sequence 2');
36
37 z=conv(x,y);
38 disp('The values of z are= ');
39 disp(z);
40 subplot(2,2,3);
41 stem(z);
42 xlabel('n');
43 ylabel('z(n)');
44 title('Convolution of Input sequence ');
45
46 z=xcorr(x,y);
47 disp('The values of z are= ');
48 disp(z);
49 subplot(2,2,4);
50 stem(z);
51 xlabel('n');
52 ylabel('z(n)');
53 title('Correlation of Input sequence ');
54
55

Printed for: [email protected]


Powered by Octave Online

http://octave-online.net

Page no:-9
Siddhesh Gupta C-53
EXP 2A

Time Reversal

Page no:-10
Siddhesh Gupta C-53
Upscaling and down scaling

EXP 2B

Page no:-11
Siddhesh Gupta C-53
EXPERIMENT 3 & 4 Z Transform and its properties

Code 1:- Z trasnsform OUTPUT

Code 2:- Z transform (having different function and ranges)

Page no:-12
Siddhesh Gupta C-53
Code 3:- Inverse Z transform using Long Division Method

Code4:- Poles and zeros

Page no:-13
Siddhesh Gupta C-53
Experiment-5

Aim:- Draw a structure of given FIR system using linear phase realization.
Given Impulse Response:-
H(n)= ⸹(n)+1/2(⸹(n-1))-1/4(⸹(n-2))+(⸹(n-4))+ 1/2(⸹(n-3))

FIR realization:-
Y(n)=[x(n) + x(n-4)] + 1/2[x(n-1) + x(n-3)] - 1/4[x(n-2)]

Structure:-

Output Waveform:-

Page no:-14
Siddhesh Gupta C-53

You might also like