0% found this document useful (0 votes)
69 views

Program To Generate Unit Step Sequence

The document describes MATLAB programs to generate and manipulate basic signal sequences including unit step, impulse, periodic, sine wave, combining sequences of different lengths, and adding two sequences. It provides the MATLAB code to generate each type of signal sequence and examples of the output generated by running the code.

Uploaded by

Sreesha Thoprath
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views

Program To Generate Unit Step Sequence

The document describes MATLAB programs to generate and manipulate basic signal sequences including unit step, impulse, periodic, sine wave, combining sequences of different lengths, and adding two sequences. It provides the MATLAB code to generate each type of signal sequence and examples of the output generated by running the code.

Uploaded by

Sreesha Thoprath
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

PROGRAM TO GENERATE UNIT STEP SEQUENCE


%n0=starting value of step sequence
%n1:n2=range
function[n,x]=step(n0,n1,n2)
n=n1:n2
x=[(n-n0)>=0];
stem(n,x)]
title(step sequence)
xlable(n------- >)
ylabel(y------- >)

OUTPUT :
Y=STEP(2,0,10)
N= 0 1 2 3 4 5 6 7 8 9 10
Y= 0 0 1 1 1 1 1 1 1 1 1

2. PROGRAM TO GENERATE IMPULSE SEQUENCE


%n0=starting value of impulse sequence
%n1:n2=range
function[n,x]=imp(n0,n1,n2)
n=n1:n2
x=[(n-n0)==0];
stem(n,x)]
title(impulse sequence)
xlable(n------- >)
ylabel(y------- >)

OUTPUT :
Y=IMP(2,0,10)
N= 0 1 2 3 4 5 6 7 8 9 10
Y= 0 0 0 0 0 0 0 0 0 0 0

3. PROGRAM TO GENERATE PERIODIC SEQUENCE


%x=periodic sequence
%n=period
function[y]=perdseq(x,N)
m=ones(1,N) ;
x1=x;
y1=x1*m ;
y2=y1( : ) ;
y=y2;
stem(y)
title(perodic sequence)
xlable(n------- >)
ylabel(y(n)------- >)

OUTPUT :
Y=perdseq([1 2 3 4],4)
Y= 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4

4. PROGRAM TO GENERATE SINE WAVE

%w=period in pi units
%n=range
function[ ]=sineseq(n,w)
y=sine(w*n) ;
subplot(2,1,1)
plot(n,y)
title(sine wave)
xlable(time------- >)
ylabel(amplitude------- >)

OUTPUT :
Y=SINESEQ(0 :100,0.1*PI)

5. PROGRAM TO MAKE EQUAL SEQUENCES


%x1=first sequence of range n1
%x2=second sequence of range n2
function[ ]=esq(n1,n2,x1,x2)
minn=min(min(n1),min(n2)) ;
maxx=max(max(n1),max(n2));
n=minn :maxx
y1=zeros(1,length(n)) ;
y2=y1 ;
a=(n>=min(n1)&(n<=max(n1)) ;
b=(n>=min(n2)&(n<=max(n2)) ;
y1(find(a))=x1
y2(find(b))=x2
OUTPUT:
ESQ([-5:2],[1:10],[2:2:16],[3,12])
N= -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10
Y1=2 4 6 8 10 12 14 16 0 0 0 0 0 0 0 0
6. PROGRAM TO ADD TWO SEQUENCES
%x1=first sequence of range n1
%x2=second sequence of range n2
function[y3]=adseq(n1,n2,n3,n4, x1,x2)
no=n1:n2
nn=n3:n4
minn=min(min(no),min(nn))
maxn=max(max(no),max(nn))
n=minn :maxn
y1=zeros(1,length(n)) ;
y2=y1 ;
a=((n>=min(no))&(n<=max(no)) ;
b=((n>=min(nn))&(n<=max(nn)) ;
y1(find(a))=x1;
y2(find(b))=x2;
y3=y1+y2
subplot(3,1,1)
stem(n1,y1)
title(sequence y1)

xlable(Range)
ylable(y1)
subplot(3,1,2)
stem(n2,y2)
title(sequence y2)
xlable(Range)
ylable(y2)
subplot(3,1,3)
stem(n,y3)
title( addition of 2 sequence )
xlable(Range)
ylable(y3)

OUTPUT:
ADSQ(0:2,[12,3],-2:3,[1 2 3 5 6 7])
N= -2 -1 0 1 2 3
Y1= 1 2 4 7 9 7

You might also like