## recarray(inarray,n)

Version 1.0.0.0 (762 Bytes) by
Creates a pseudo-recursive version of simple 1D arrays
Updated 6 Mar 2018

This is a cross between the built-in 'repmat' and 'perm' functions, though neither are used here. If you input a simple 1D array and the number of 'repetitions' you want, this function repeats the array for each element of the array, for each element, for each element, and so on, depending on how many repetitions you are asking for.
For example, you may have an array [a b c d] and you want 3 recursive repetitions. This function (recarray([a b c d],3) would yield the result:
|a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d a b c d|
|a a a a b b b b c c c c d d d d a a a a b b b b c c c c d d d d a a a a b b b b c c c c d d d d a a a a b b b b c c c c d d d d|
|a a a a a a a a a a a a a a a a b b b b b b b b b b b b b b b b c c c c c c c c c c c c c c c c d d d d d d d d d d d d d d d d|

I use this everywhere I use matlab, mostly for indexing, and got a little tired of trying to recreate it every time I move to a new desk. So, I'm uploading it here. Hopefully other people will find it useful.

### Cite As

ja (2024). recarray(inarray,n) (https://www.mathworks.com/matlabcentral/fileexchange/66390-recarray-inarray-n), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility
Created with R2017b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux
##### Categories
Find more on Numeric Types in Help Center and MATLAB Answers