Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
27 views

1.program For Discrete Time Sinusoidal Signal?: All All

The document contains MATLAB code to generate and plot different types of discrete time signals including a discrete sinusoidal signal, unit impulse signal, unit step signal, exponential signal, and sinusoidal signal. The code provides functions to generate unit impulse and unit step signals and examples of plotting the various signal types individually and together in a subplot.

Uploaded by

asutoshitsme
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

1.program For Discrete Time Sinusoidal Signal?: All All

The document contains MATLAB code to generate and plot different types of discrete time signals including a discrete sinusoidal signal, unit impulse signal, unit step signal, exponential signal, and sinusoidal signal. The code provides functions to generate unit impulse and unit step signals and examples of plotting the various signal types individually and together in a subplot.

Uploaded by

asutoshitsme
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

1.Program for discrete time sinusoidal signal?

clc
clear all
close all
n=[-2 -1 0 1 2 3];
x=[2 4 5 3 -2 -1];
stem(n,x);
xlabel('no of samples');
ylabel('x(n) ------');
title('discete time signal');

2.program to generate an discrete time unit impulse signal.


function[del,n]=impseq(n0,n1,n2)
n=n1:n2
del=[(n-n0)==0]
end
clc
clear all
close all
n0=5;
n1=-20;
n2=20;
[del,n]=impseq(n0,n1,n2)
stem(n,del);
xlabel('n ------>')
ylabel('del(n) ---->')
title('unit impulse signal')

3. program to generate unit step signal.

function[u,n]=unitstep(n0,n1,n2)
n=n1:n2
u=[(n-n0)>=0]
end
clc
clear all
close all
n0=5;
n1=-20;
n2=30;
[u,n]=unitstep(n0,n1,n2)
stem(n,u);
xlabel(' n------->')
ylabel('u(n)----->')
title('unit step sequence')

4.program to generate discrete time exponential sequence


clc

clear all
close all
n1=input('enter the value of n1')
n2=input('enter the value of n2')
a=input('enter the value of a')
n=n1:n2
x=a.^n
stem(n,x)
xlabel('n-------->')
ylabel('a^n----->')
title('discrete time exponential sequence')

5.program to generate sinusoidal discrete time signal


clc
clear all

close all
n1=input('enter the value o n1:')
n2=input('enter the value of n2:')
n=n1:n2
x=3*cos((0.5*pi.*n)+(pi/3))+2*sin(0.3*pi.*n)
stem(n,x)
xlabel('n---->')
ylabel('x(n) ----->')
title('discrete time sinusiodal signal')

7.program to generate different type of signal.


clc
clear all

close all
n=[-2 -1 0 1 2 3];
x=[2 4 5 3 -2 -1];
subplot(2,2,1);
stem(n,x);
xlabel('no of samples');
ylabel('x(n) ------');
title('discete time signal');

n0=5;
n1=-20;
n2=20;
[del,n]=impseq(n0,n1,n2)
subplot(2,2,2);
stem(n,del);
xlabel('n ------>')
ylabel('del(n) ---->')
title('unit impulse signal')
n0=5;
n1=-20;
n2=30;
[u,n]=unitstep(n0,n1,n2)
subplot(2,2,3);
stem(n,u);
xlabel(' n------->')
ylabel('u(n)----->')
title('unit step sequence')

n1=input('enter the value of n1')


n2=input('enter the value of n2')
a=input('enter the value of a')
n=n1:n2
x=a.^n
subplot(2,2,4)
stem(n,x)
xlabel('n-------->')
ylabel('a^n----->')
title('discrete time exponential sequence')

You might also like