function [x]=FourierMat(a, b, f, time, t1);
%FourierMat.m
%
% [x] = FourierMat(a, b, f, time, t1)
%with provided a,b,f,time and t1 this function returns the
%values of Fourier series.
%a and b are the coefficients of the series, their size is: [n,1]
%f is the frequencies of size [1,n]
%time is a column vector with the time steps of size [2(n-1),1]
%t1 is the first time step. we need to substract this value from all time vector
if (size(a) ~= size(b))
	error('size of a and b  mismatched');
end;
if (size(a') ~= size(f));
	error('size of f and a,b  mismatched');
end;
% if (length(time) ~= 2*(length(a)-1));
% 	error('size of time and a,b  mismatched');
% end;
dt = time(2) - time(1);
time = time - t1; %shift all times to t(j)-t(1)
f = (2*pi)*f;
F = time(:) * f;%force time to be column
C = cos(F);
S = sin(F);

x = C*a + S*b; %Fourier series values