Stack Function
stack(...) returns a vector or matrix formed by placing its arguments top to bottom. The arguments must be arrays with the same number of columns, or they must be scalars and column vectors.
For scalar values, stack() returns a column vector containing the list of arguments.

In the next example, three column vectors, a, b, and c, are passed as arguments to stack().

To obtain a matrix, the vectors must be in row form. Here, the three row vectors d, f, and g are passed as arguments to stack().

Row vectors can easily be turned into columns in the matrix by applying a matrix transpose to stack().

See also¶
This page is based on a legacy wiki article by Edward Ulle.