Versión (1,88 KB) por Matt Fig
Replicate and tile each element of an array.
2,6K descargas
Actualizado 24 jun 2009

Ver licencia

Nota del editor: This file was selected as MATLAB Central Pick of the Week

EXPAND(A,SZ), for array A and vector SZ replicates each element of A by SZ. The results are tiled into an array in the same order as the elements of A, so that the result is size: size(A).*SZ.

Therefore the number of elements of SZ must equal the number of dimensions of A, or in MATLAB syntax:


must be true.
The result will have the same number of dimensions as does A.
There is no restriction on the number of dimensions for input A.


>> A = [1 2;3 4]
A =
1 2
3 4
>> expand(A,[2 1])
ans =
1 2
1 2
3 4
3 4
>> expand(A,[2 2])
ans =
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4

Please email me if bugs are found in the code. Thanks.

Citar como

Matt Fig (2024). EXPAND (https://www.mathworks.com/matlabcentral/fileexchange/24536-expand), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2007a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Más información sobre Matrices and Arrays en Help Center y MATLAB Answers.

Inspirado por: REPLICATE

Community Treasure Hunt

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

Start Hunting!
Versión Publicado Notas de la versión

Added kron to the see also list.