function F = damp(T, t0, offset, period, amp, decay, phase=0)

  for i = 1 : length(T)
  
    if ( T(i) < t0 )
      F(i) = offset;
    else
      y = cos(phase + 2*pi/period*(T(i)-t0));
      a = amp * exp(-decay*(T(i)-t0));
      F(i) = y * a + offset;
    endif
  
  endfor

endfunction