# MATLAB: How to extract multiple subsequences from a set of values

dataextractionsetssubsets

Basically I'm given a set of values x=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]; and I would like to extract a set of values from this set such that it divides the entire set based on divisibility by 5, and puts each subset in an array.
The desired outputs are:
m1 = [1, 2, 3, 4, 5]
m2 = [6, 7, 8, 9, 10]
m3 = [11, 12, 13, 14, 15]
m4 = [16, 17, 18, 19]
Here's my code. It works the way I want it to work, but I know there's a much better way of iterating through the set– I just can't wrap my head around it. I'd like to be able to apply it to larger sets of data, for instance when the elements of x go up to 10000.
clcclearclose allx=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19];n=1;for i = 1:1:length(x)    if (mod(x(i),5)==0 && i>1)        ind(n) = i; n = n+1;    endendm1 = []; m2 = []; m3 = []; m4 = [];i = 1;% First sequenceif i<(ind(i)+1)      m1(i) = x(i);endfor j = 1:ind(i)    m1(j) = x(j);end  for k = ind(i)+1:ind(i+1)    m2(k-ind(i)) = x(k);endfor l = ind(2)+1:ind(3)    m3(l-ind(2)) = x(l);end % Last sequencefor z = ind(3)+1:length(x)        m4(z-ind(3)) = x(z);end

 x=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19];  m = length(x) ;  n = 5 ;  x = [x NaN(1,(n - rem(m,n)))] ; % make x divisble by n by length iwant = reshape(x,n,[])'iwant = 4×5     1     2     3     4     5
●