MATLAB: I WANT TO FIND CORRELATION OF X[N] WITH X[N],X[N] WITH Y[N] AND Y[N] WITH Y[N].

correlation

GIVEN THAT x[n] = cos(2πf0nT), T = 1 sec, f0 = 0.113 Hz, n = 0,1,…,99 AND y[n] = randn(1,100).

Best Answer

Harshad
1.- you are not taking many points/cycle in x(n).
In other words, the more points you can get in a single cycle of the tone x the better. Because you are correlating noise that can take values equal to tx(n) amplitude, and with just a few samples/cycle of x(n), the correlation will lose data.
2.- since x is periodic, for instance
figure(1);plot(xcorr(x,x))
this is not really meaningful
3.- Now let's look at what happens correlating just one cycle:
format long
f0=.113
T=1
n=[-100:100]
x=cos(2*pi*f0*n*T)
y=randn(1,0)
x1cycle=x([101:101+floor(1/f0)+1])
r_x1c_y=xcorr(x1cycle,y)
figure(2);plot(r_x1c_y)
now we can see the tone x(n) heavily corrupted by noise y.
This is one of the correct ways to correlate cyclic signals with signals that do not look like cyclic.
Regardless of the length of the sequence, because the signal x(n) is periodic, it has no finite energy.
In such case, we have switched to analyze a single cycle, where x(n) has finite energy.
4.- recommended reading
MATLAB CENTRAL recommends
[1] Buck, John R., Michael M. Daniel, and Andrew C. Singer. Computer Explorations in Signals and Systems Using MATLAB. 2nd Edition. Upper Saddle River, NJ: Prentice Hall, 2002.
[2] Stoica, Petre, and Randolph Moses. Spectral Analysis of Signals. Upper Saddle River, NJ: Prentice Hall, 2005.
I also recommend:
[3] Probability of Random Variables and Stochastic Processes: A.Papoulis S.Pillai 4th ed ISBN: 0-07-366011-6 pg210
If you find this answer of any help solving this question, please click on the thumbs-up vote link,
thanks in advance
John