Qu

cat

Builtin index · Core maths

result = cat(dim, a, b, ...)

Input: dim, a, b, ... · Output: result

What it is

MATLAB-style concatenation: dim (a scalar, 1 or 2) selects the axis, then the 2+ remaining arguments (same shape rules as hstack/vstack) are joined along it — dim=1 vertical (same as vstack), dim=2 horizontal (same as hstack).

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = cat(dim, a, b, ...)
dim scalarMATLAB-style concatenation: dim (a scalar, 1 or 2) selects the axis, then the 2+ remaining arguments (same shape rules as hstack/vstack) are joined along it — dim=1 vertical (same as vstack), dim=2 horizontal (same as hstack).
a scalarMATLAB-style concatenation: dim (a scalar, 1 or 2) selects the axis, then the 2+ remaining arguments (same shape rules as hstack/vstack) are joined along it — dim=1 vertical (same as vstack), dim=2 horizontal (same as hstack).
b —Taking the axis first means cat is the one array builtin you cannot write as a.cat(b) or a.
... repeatablenot documented yet
result Mat
Returns a Mat. Taking the axis first means cat is the one array builtin you cannot write as a.cat(b) or a

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

A = [1, 2, 3; 4, 5, 6]
print("size={size(A)}  numel={numel(A)}")
print(eye(3))
print(identity(2))
p = [1, 2]
q = [3, 4]
print(cat(1, p, q))   # vertical: stacks rows

print(cat(2, p, q))   # horizontal: concatenates

output
size=[2, 3]  numel=6
[1, 0, 0; 0, 1, 0; 0, 0, 1]
[1, 0; 0, 1]
[1, 2; 3, 4]
[1, 2, 3, 4]

from core-math

How it works

cat(dim, a, b, ...) — MATLAB's own general concatenation form, matched exactly (dim=1 vertical, dim=2 horizontal): a direct, checkable spec to match rather than a Qu-specific convention.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.