function [Fcoeff] = interpFS (valFS)
%
% interpFS interpolates valFS by a trigonometric polynomial
% and stores the Fourier coefficients in the format
% [a_M,...,a_1,a_0,b_1,...b_{M-1}]. 
% if length (valFS) is odd, 0 is returned.
% Regard that N should be even, else it is increased by 1.
%

% Determine length of valFS. Make sure it's a column.
n = length (valFS);
valFS = reshape (valFS, n, 1);

% Determine length of the vector and of the sine and
% cosine coefficients.
if mod (n,2)
    display ('number of points is not even')
    Fcoeff = 0;
    return;
end

M = n / 2;

% Initialize coefficient vector
Fcoeff = zeros (n, 1);

% Compute the FFT of the given values and store it in the original
% location
valFS = fft (valFS);

% Compute the real coefficients from the complex ones and store
% everything in the correct format
Fcoeff (1:M+1) = flipud (2. * real (valFS(1:M+1))) / n;
Fcoeff (M+2:n) = -2. * imag (valFS(2:M)) / n;

end