MATLAB: How to isolate data from a large input file

isolatelarge data sets

I have a number of large data files with approximately 8,000,000 rows and 10 columns. The data is taken from a train and monitors various inputs over a number of days. The 10th column indicates direction of the train with 1 and -1 for differing direction and 0 for when the train is at a standstill.
Each time the train changes direction I would like to be able to create a new variable that stores all the following data until the next direction change.
I am able to do this manually, by examining the data and finding the index where a direction change is indicated, i.e. 1 becomes -1. I would like to make a process that could automate this.
Any help would be greatly appreciated.

Best Answer

I suggest not using a new variable but indexing into the one.
A very useful coding scheme easy to deal with.
To find the direction changes, use
ixdir=find(abs(diff(x(:,10))==2))+1; % all the points of direction change
The first direction section is from 1:ixdir(1); second is then ixdir(1):ixdir(2), etc., ... Processing those in sequence is quite easy with the indices w/o different variables.