
%
%
%
  clear all

%
% Define time vector, the response y, and normally distributed noise.
%

  per = 0.1;
  t = 0:0.01:2;
  t2 = 0:0.02:2;
  k = 22.1;
  km = k-per*k;
  kp = k+per*k;
  y = 2*sin(t*sqrt(k));
  nt = length(t);
  nk = 20;
  sigma = 0.5;
  sigma2 = sigma^2;
  sigma_k = 1.1;
  sigma_k2 = sigma_k^2;
  kdist = km + 2*per*k*rand(nk,1);
  kdist_norm = k + sigma_k2*randn(nk,1);

  ve = sigma2*randn(1,nt);
  

  y_err = y + ve;

  for i=1:nk
    y_err_k(i,:) = 2*sin(t2*sqrt(kdist(i)));
    y_err_k_norm(i,:) = 2*sin(t2*sqrt(kdist_norm(i)));
  end

%
% Plot the signal and noise.
%

  figure(1)
  plot(t,y,'-k',t,y_err,'xb','linewidth',3)
  axis([0 2 -2.5 2.5])
  hold on
  plot(t,0*t,'-k','linewidth',3)
  hold off
  set(gca,'Fontsize',[20]);
  xlabel('Time (s)')
  ylabel('Displacement')
  %print -depsc fig5_6a

  figure(2)
  plot(t,y,'-k',t2,y_err_k,'xb','linewidth',3)
  axis([0 2 -2.5 2.5])
  hold on
  plot(t,0*t,'-k','linewidth',3)
  hold off
  set(gca,'Fontsize',[20]);
  xlabel('Time (s)')
  ylabel('Displacement')
  %print -depsc fig5_6b

  figure(3)
  plot(t,y,'-k',t2,y_err_k_norm,'xb','linewidth',3)
  axis([0 2 -2.5 2.5])
  hold on
  plot(t,0*t,'-k','linewidth',3)
  hold off
  set(gca,'Fontsize',[20]);
  xlabel('Time (s)')
  ylabel('Displacement')


