# MATLAB: How to divide a dataset into trials using a specific delimiter

eyetracking data

Hello,
I have a dataset of eye-tracking data that looks like so:
Time    X       Y192  15  NaN499  609  519499  608  519.       .       ..       .       ..       .       .1200    800     NaN1201    750     600.       .       ..       .       ..       .       .2000    792     NaN
All lines between 2 consecutive NaNs correspond to a trial, I would like to create a cell array where each cell contains all the rows from one trial. Can you help me on how to procede?
Thank you

• nanpos = find(isnan(YourData(:,3))]);nanruns = diff([1 nanpos size(Yourdata,1)]);blocks = cell2mat(YourData, nanruns, size(YourData,2));blocks( cellfun(@isempty, blocks) ) = [];