function [res] = time_series( input_matrix, total, interval )
% Generate time series plots
%   input_matrix: the imported dataset, in matrix form
%   total: the total number of nodes
%   interval: the time interval to be used, in seconds

% Calculate duration
maxt = max(input_matrix);
maxt = maxt(4);
maxt = uint32(maxt);

mint = min(input_matrix);
mint = mint(3);
mint = uint32(mint);

interv = maxt - mint;

% Number of time intervals
interv = uint32(ceil(interv / interval));

array = zeros(1,interv);

s = size(input_matrix);

nrows = s(1);

cont = 1;

while (cont<=interv)
    for ii = 1:nrows
       if (input_matrix(ii,1) <= total) && (input_matrix(ii,2) <= total) 
            avg = (input_matrix(ii,3)+input_matrix(ii,4))/2;    % Average between beginning and end of the contact
            if (avg >= mint) && (avg <= (mint+interval))
                array(cont) = array(cont) + 1;
            end
       end
    end
    mint = mint + interval;
    cont = cont +1;
end


plot(array, '-ob', 'MarkerFaceColor','b', 'MarkerSize', 3);  
legend('Data');
xlabel('Time interval');
ylabel('Number of contacts');
title('Contacts by time');

% Generate autocorrelation plot
% autocorr(array,interv-1)

return;
end


