recarray(inarray,n)

版本 1.0.0.0 (762 字节) 作者: ja
Creates a pseudo-recursive version of simple 1D arrays
10.0 次下载
更新时间 2018/3/6

查看许可证

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.

引用格式

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

MATLAB 版本兼容性
创建方式 R2017b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Numeric Types 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0