clc clear all; close all; x = input('enter the sequence :'); px=input('pointer position of x : '); a = input('enter the impulse sequence :'); ph=input('pointer position of h : '); for i= 1:length(a) h(i) = a(length(a)+1-i); end lx=length(x); lh=length(h); left=1-px; right=lx-px; left1=-(lh-ph); right1=-(1-ph); t=[left:right]; t1=[left1:right1]; subplot(3,1,1) stem(t,x) title('input sequence(x)') subplot(3,1,2) stem(t1,a) title('input sequence(h)') for i= 1:lh ph(i) = h(lh+1-i); end t3=[-right1:-left1]; x1 = [zeros(1,lh-1), x , zeros(1, lh-1)]; ly = lx+lh-1; for i = 1:ly z = x1(1, 1:length(ph)) .*ph; y(i) = sum(z); ph = [ 0 ph]; end y t4 = [left+left1:right+right1]; subplot(3,1,3) stem(t4,y) if(x==a) title('auto-corelation signal(y)') else title('cross-corelation signal(y)') end