I am running a solution on an eye tracking system at 1000Hz. Data comes in from the eye tracker in the form of a X and Y gaze position co-ordinate. I am trying to add these two co-ordinates to the end of an array as they come in.
My current solution is as follows:
gazePositionArray = [];
while gazeDataIsAvailable
[x y] = getNewCoordinates;
gazePositionArray = [gazePositionArray; x y];
end
The problem lies in the fourth line. In order for the array to update, it copies the contents of the old array and adds the new co-ordinates on the end. This is fine, for example, for the first 30 seconds of recording, but the more data exists in the array, the more processing the computer has to do in order to create the new array (after 30 seconds the system is trying to copy 30,000 lines of data 1000 times per second - with this getting more and more at each iteration)
Is there a way to append a row to the end of a MATLAB array without the system having to copy the whole array into itself?