function  y = cpole2t(cp,res,t)
%CPOLE2T y = cpole2t(cp,res,t)
%        Performs inverse Laplace transform for two complex 
%        conjugate poles and generates a time function. 
%Inputs: cp - complex pole, having POSITIVE imaginary part
%        res - residue at the complex pole
%        t - time vector
%Output: y - time response vector
% 
%        The response is computed as 
%        y(t) = 2 K exp(a*t) cos(omega*t + phi)
%          where res = K exp(j phi), cp = a + j omega


a = real(cp);omega = imag(cp);
K = abs(res);phi = angle(res);
y = 0*t;
for n=1:length(t),
   y(n) = 2*K*exp(a*t(n))*cos(omega*t(n)+phi);
end
%----- remove any very small imaginary parts
y = real(y);

