function [g, phi] = spectro_tfe(x1, x2, f0, fs, t)
% spectro_tfe computes an absolute value of the complex gain at f0 and an
% argument of the complex value at f0 by using a FFT
%
%% Syntax:
%
% [g, phi] = spectro_tfe(x1, x2, f0, fs, t)
%
%% Description:
%
% This function computes an absolute value of the complex gain 
% and an argument of the complex gain for one frequency f0 by using a FFT. 
% The complex gain is represented by a transfer function at f0.
% This function uses also a vector t and a sampling frequency
% for f0 determitation, that means the
% value of the f0 is changed into a number of the sample 
% from which the complex gain is estimated. The value of this sample
% represents an amplitude maximum in the sinusoid.
%
%% Inputs:
%
% x1: a 1-by-n vector containing an input sinusoid, n is a number of
%     samples
%
% x2: a 1-by-n vector containing an another input sinusoid, n is a number
%     of samples
%
% f0: a scalar value of sinusoid frequency
%
% fs: a scalar value containing a sampling frequency
%
% t: a 1-by-n vector containing samples of sinusoid (a sampled time 
%    of a sinusoid duration)
%
%% Outputs:
%
% g: a scalar represents the absolute value of the complex gain at f0
%
% phi: a scalar containing the argument of the complex gain at f0
%
%% Author: Veronika Svozilová
%% Date: 13/04/2015
%
ind = ceil((f0*(length(t)-1)/fs)+1);
X1 = fft(x1);
X2 = fft(x2);
G = X2(ind)/X1(ind);
g = abs(G);
phi = angle(G);
end