%For generating the outcome of the random process that have two single tone
%frequencies e^(j*2*pi*(1/5)*n) +e^(j*2*pi*(1/8)*n) with random phase and
%amplitudes.
%Frequencies are fixed
%Each cell contains two elements. The first two cells are initialized and
%the other cells are generated using the recursive expression given below.
%alpha 1 and alpha 2 are obtained statistically.
MATRIX1=[2 exp(j*2*pi*(1/5))+exp(j*2*pi*(1/8));exp(-j*2*pi*(1/5))+exp(-j*2*pi*(1/8)) 2];
VECTOR=[exp(-j*2*pi*(1/5))+exp(-j*2*pi*(1/8)) exp(-j*2*pi*(2/5))+exp(-j*2*pi*(2/8))];
ALPHA=pinv(MATRIX1)*transpose(VECTOR);
alpha1=ALPHA(1);
alpha2=ALPHA(2);
X{1}=[exp(j*2*pi*(1/5))+exp(j*2*pi*(1/8))  2];
X{2}=[exp(j*2*pi*(2/5))+exp(j*2*pi*(2/8)) exp(j*2*pi*(1/5))+exp(j*2*pi*(1/8))];
for n=3:1:1000
X{n}=alpha1*X{n-1}+alpha2*X{n-2};
end
SIGNAL1=cell2mat(X');
n=0:1:1000;
SIGNAL2=exp(j*2*pi*(1/5)*n)+exp(j*2*pi*(1/8)*n);
figure(1)
subplot(4,1,1)
plot(real(SIGNAL1(:,1)))
subplot(4,1,2)
plot(imag(SIGNAL1(:,1)))
subplot(4,1,3)
plot(real(SIGNAL2(1,:)),'r')
subplot(4,1,4)
plot(imag(SIGNAL2(1,:)),'r')



