Algorithm 2:
Define x(n)
Define y(n)
Rotate (that is reverse) the signal h(n) using the MATLAB function fliplr(h) where h is to be flipped (i.e, rotated).
Find the convolution between x(n) and flipped version of h(n).
Plot the resultant signal
Program
% Program to find correlation of two signals
x=input ('Enter the first sequences x(n) : ');
h=input(' Enter the second sequences h(n) : ');
n1 =length(x)-1;
n2=length(h)-1;
r=conv(x,fliplr(h));
t=(-n1):n2;
stem(t,r);
xlabel(' lag index ');
ylabel(' Amplitude ');
v=axis;
axis([-n1 n2 v(3:end)]);
-------------------------------------------------------------------
Εγγραφή σε:
Σχόλια ανάρτησης (Atom)
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου