function [ timePoint1Matrix, timePoint2Matrix ] = timeSplitter( fullCoordinates, timePoint1, timePoint2 )
%This function splits parts of a large matrix into two smaller metrices
%This function is needed to connect particles in two consecutive time
%points. It is used to pass coordinates in consecutive time frames to a 
%particle tracking algorithm that at every step can only look at two 
%time points.

time1coordinates = find (fullCoordinates(:,4) == timePoint1); 
%finds all the maximum coordinates that are from timepoint1
numberOfPoints1Min = min(time1coordinates);
numberOfPoints1Max = max(time1coordinates);
%indexes the range of maximum coordinates from timepoint1

timePoint1Matrix = fullCoordinates(numberOfPoints1Min:numberOfPoints1Max, 1:3);
%copies all maximum coordinates that are in the range to a unique matrix
...for time point 1

%This next section repeats for the next time point
time2coordinates = find (fullCoordinates(:,4) == timePoint2); 

numberOfPoints2Min = min(time2coordinates);
numberOfPoints2Max = max(time2coordinates);

timePoint2Matrix = fullCoordinates(numberOfPoints2Min:numberOfPoints2Max, 1:3);

end

