hcat

hcat(A...)

Concatenate along dimension 2

Examples

julia> A = [1 2 3; 4 5 6];
julia> B = [7 8; 9 10];
julia> C = [11; 12];
julia> hcat(A, B, C)
2×6 Array{Int64,2}:
 1  2  3  7   8  11
 4  5  6  9  10  12

This example demonstrates the use of hcat to concatenate arrays A, B, and C along dimension 2. The resulting array has 2 rows and 6 columns.

Common mistake example:

julia> A = [1 2 3; 4 5 6];
julia> B = [7 8; 9 10];
julia> C = [11; 12];
julia> hcat(A, B, C, [13 14])
ERROR: DimensionMismatch("arrays could not be broadcast to a common size")

In this example, an error occurs because the dimensions of the arrays being concatenated are not compatible. It's essential to ensure that the arrays being concatenated have compatible dimensions along the concatenation dimension.

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: