getcolumn

Extracts one column of a matrix as a column vector.

Category: Other public functions: graph2d

Syntax

c = getcolumn(A, k)

Returns column k of A.

Description

It is a helper that does the same as A(:, k), handy where an indexing expression cannot be written inline. It is not documented in the function reference, so new code should write the indexing directly.

Input arguments

A
A matrix.
k
Index of the column.

Output arguments

c
Column vector with the k-th column of A.

Example

Second column

A = [1 2; 3 4];
c = getcolumn(A, 2)
Output
c = 2×1

     2
     4

See also

colon size reshape diag