%  Example 3.1.  Generates a sample function and plots the analytic 
%  correlation function.
clear
%  Input the time sample vector.
t=0:.01:9.99;
%  Allocate memory to the sample function.
u=zeros(1,1000);
%  Generate the sample function.
for k=0:9,
  u(100*k+1:100*k+100)=(.6*rand-.3)*ones(1,100);
end
%  Plot the sample function
set(0,'DefaultAxesFontName','times')
set(0,'DefaultAxesFontSize',16)
set(0,'DefaultTextFontName','times')
figure(1)
clf
plot(t,u)
xlabel('Time (sec)')
ylabel('Voltage')
grid on
axis([0 10 -0.3 0.3])
%  Generate the correlation function (from the analytic results).
x=[-3 -2.9999 -2 -1.999 -1 -.9999 0 .0001 1 1.0001 2 2.0001 3];
y=[-3 -2.9999 -2 -1.999 -1 -.9999 0 .0001 1 1.0001 2 2.0001 3];
z=zeros(13);
z(2:3,2:3)=.03*ones(2);
z(4:5,4:5)=.03*ones(2);
z(6:7,6:7)=.03*ones(2);
z(8:9,8:9)=.03*ones(2);
z(10:11,10:11)=.03*ones(2);
z(12:13,12:13)=.03*ones(2);
%  Plot the correlation function.
figure(2)
clf
mesh(x,y,z)
xlabel('{\itt}_1')
ylabel('{\itt}_2')
zlabel('{\itR}_{\itx}')
axis([-3 3 -3 3 0 .05])