%
%
  clear all
%
%
  K = 0.1;
  delta = 0.5;
  omega_F = 10*pi;

  t = 0:.005:1;
  y = K*cos(omega_F*t - delta);
  for n=1:10
    t1(n) = (1/omega_F)*((2*n-1)*pi/2 + delta);
  end
  y1 = K*cos(omega_F*t1 - delta); 

  sigma = sqrt(.1);
  nt = length(t);
  ve = sigma*randn(1,nt);
  y_err = y + ve;

  Y_err = fft(y_err,512);
  Pyy = Y_err.* conj(Y_err)/512;
  f = 1000*(0:256)/512;

%
%
  figure(1)
  plot(t,y,'k-','linewidth',2)
  hold on
  plot(t1,y1,'xb','linewidth',8)
  plot(t,0*y','k-','linewidth',2)
  hold off
  legend('y(t)','y_i','Location','NorthEast')
  set(gca,'Fontsize',[20]);
  xlabel('Time (s)')
  ylabel('Displacement (m)') 

  figure(2)
  plot(t,y_err,'xk','linewidth',3)
  hold on
  plot(t,0*y','k-','linewidth',2)
  hold off
  set(gca,'Fontsize',[20]);
  xlabel('Time (s)')
  ylabel('Displacement (m)')

  figure(3)
  plot(f,Pyy(1:257))
  set(gca,'Fontsize',[20]);
  xlabel('frequency (Hz)')


