Correlation between Two Finite Signals
Algorithm 1:
Cross correlation is defined as, if x(n) and h(n) are finite signals then cross correlation
In cross correlation folding of h(n) doesn’t occur.
- Input the first sequence.
- Input the second sequence
3. Find the cross correlation of these sequences using the MATLAB function "xcorr(x,h)" where x and h are the sequences to be correlated.
- Plot the result
Program
% Program to find correlation of two signals
x=input ('Enter the first sequences ');
h=input(' Enter the second sequences ');
c= xcorr(x,h);
t=0 : (length(x) +length(h)-2);
stem(t,c);
-------------------------------------------------------------------------------------------------
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)]);
------------------------------------------------------------------------------------------------
No comments:
Post a Comment
Your Comments... (comments are moderated)