transpose

transpose(A)

The transposition operator (.').

Examples

julia> A = [1 2 3;
            4 5 6;
            7 8 9];
julia> transpose(A)
3×3 Transpose{Int64,Array{Int64,2}}:
 1  4  7
 2  5  8
 3  6  9
  1. Transpose a matrix:

    julia> A = [1 2 3; 4 5 6; 7 8 9];
    julia> transpose(A)
    3×3 Transpose{Int64,Array{Int64,2}}:
    1  4  7
    2  5  8
    3  6  9

    It transposes the matrix A, flipping the rows and columns.

  2. Transpose a vector:

    julia> v = [1, 2, 3, 4];
    julia> transpose(v)
    4×1 Transpose{Int64,Array{Int64,1}}:
    1
    2
    3
    4

    It converts the vector v into a column matrix.

  3. Transpose a string:
    julia> s = "hello";
    julia> transpose(s)
    5×1 Transpose{Char,Array{Char,1}}:
    'h'
    'e'
    'l'
    'l'
    'o'

    It converts the string s into a column matrix of characters.

Common mistake example:

julia> A = [1 2 3;
            4 5 6];
julia> transpose(A)
ERROR: DimensionMismatch("matrix is not square: dimensions are (2, 3)")

In this example, the matrix A is not square, resulting in a DimensionMismatch error. The transpose operation requires the matrix to be square (equal number of rows and columns). Ensure that the matrix dimensions are compatible before applying the transpose function.

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: