transpose
This function transposes an m x n matrix to a n x m matrix.
The matrix must not necessarily be recctangular. All matrices can be transposed if the number of elements in the
rows below contain the same number of elements or fewer elements than the previous row. Otherwise, the matrix cannot
be transposed due missing values to include.
Indirect parameter passing is disabled
1
No. | Type | Description |
---|---|---|
1 input |
matrix | input matrix Matrix to be transposed |
Type | Description |
---|---|
matrix | Transposed matrix |
echo( transpose( { {1,2,3,4}, {a,b,c,d}, {5,6,7,8} } ) ); // Rectangular matrix
echo( transpose( { {1,2,3,4}, {a,b,c}, {5,6} } ) ); // Bottom rows with fewer elements
// echo( transpose( { {1,2,3,4}, {a,b,c}, {5,6,7,8} } ) ); // Would cause an exception
{{1,'a',5},{2,'b',6},{3,'c',7},{4,'d',8}}
{{1,'a',5},{2,'b',6},{3,'c'},{4}}