Professional Documents
Culture Documents
Write A Program For - A) Addition B) Subtraction C) Convolution of Two Sequences
Write A Program For - A) Addition B) Subtraction C) Convolution of Two Sequences
ANS:
A) Addition
x=input('Enter the first sequence');
subplot(3,1,1);
stem(x);
title('X');
y=input('Enter the second sequence');
subplot(3,1,2);
stem(y);
title('Y');
z=x+y;
subplot(3,1,3);
stem(z);
title('Z=X+Y');
OUTPUT
OUTPUT
Enter the first sequence[6 5 9 8]
Enter the second sequence[2 6 9 4]
c)Convolution
OUTPUT
b) Ramp signal
c) Impulse signal
t = (-1:0.1:3)';
impulse = t==0;
unitstep = t>=0;
ramp = t.*unitstep;
figure(1); stem(t,impulse);
figure(2); stem(t,unitstep);
figure(3); stem(t,ramp);
Impulse signal
Unit Step signal
Ramp Signal
3. Perform following operations on any signal.
a) Shifting
Ans:
Shifting Operation
clc;
clear all;
close all;
x=input('Enter the sequence of x(n)');
xl=input('Enter the lower limit of x(n)');
d=input('Enter the number of samples to be delayed');
a=input('Enter the number of samples to be advanced');
l=length(x);
xu=l+xl-1;
p=xl:1:xu;
subplot(4,1,1);
stem(p,x);
title('Graph of x(n)');
subplot(4,1,2);
stem(-p,x);
title('Graph of x(-n)');
q=(xl+d):1:(xu+d);
subplot(4,1,3);
stem(q,x);
title('Graph of delayed sequence of x(n)');
r=(xl-a):1:(xu-a);
subplot(4,1,4);
stem(r,x);
title('Graph of advanced sequence of x(n)');