MATLAB: Extracting certain data from multiple column vectors

extracting datafor loop

So I have 50 different 1 column vectors that I need to extract certain data from each vector. I need to define a new vector when t(i+1) < t(i). So there is one drop in my vector and I need to be able to find it, then create a new vector with only the information from that point until the end of the vector without overwriting the other vector. Each of the 50 vectors I have all have a different number of rows and this drop point of my data all happens in a different spot too. How do I write a for/if loop to find this new set of data?

Best Answer

splitVec = @(V) mat2cell(V(:), diff([0; find(diff(V(:))<0); length(V)]), 1);
If your 50 vectors are in a cell array, say V50, then you can
cellfun(splitVec, V50, 'Uniform', 0)