MATLAB: Repetitive sequence with calculations

iterationssequence

Hello all,
I am trying to create the following sequence of numbers:
5 6 7 5 6 7 5 6 7 8 9 10 8 9 10 8 9 10 11 12 13 …
To be more specific, 5 6 7 will be repeated three times and then +1 to each element and repeat another three times. The amount of iterations would be pre-defined f.e. n times.
This is what I tried but it didn't work:
a=[5 6 7]
x = []
n=9
for i=1:n
s=3+a
for j=1:3
m(i,j)=s(i)
end
b=s+3
x = [x,b];
end
Huge thanks in advance!

Best Answer

a=[5 6 7];
x=zeros(1,9*n);
for j=1:n
x(9*(j-1)+1:9*j)=repmat(a,1,3);
a=a+3;
end