Main Content

colnames

Retrieve or set column names of DataMatrix object

Syntax

ReturnColNames = colnames(DMObj)
ReturnColNames = colnames(DMObj, ColIndices)
DMObjNew = colnames(DMObj, ColIndices, ColNames)

Input Arguments

DMObj

DataMatrix object, such as created by DataMatrix (object constructor).

ColIndices

One or more columns in DMObj, specified by any of the following:

  • Positive integer

  • Vector of positive integers

  • Character vector specifying a column name

  • Cell array of character vectors

  • Logical vector

ColNames

Column names specified by any of the following:

  • Numeric vector

  • Cell array of character vectors

  • Character array

  • Single character vector, which is used as a prefix for column names, with column numbers appended to the prefix

  • Logical true or false (default). If true, unique column names are assigned using the format col1, col2, col3, etc. If false, no column names are assigned.

Note

The number of elements in ColNames must equal the number of elements in ColIndices.

Output Arguments

ReturnColNamesCharacter vector or cell array of character vectors containing column names in DMObj.
DMObjNew

DataMatrix object created with names specified by ColIndices and ColNames.

Description

ReturnColNames = colnames(DMObj) returns ReturnColNames, a cell array of character vectors specifying the column names in DMObj, a DataMatrix object.

ReturnColNames = colnames(DMObj, ColIndices) returns the column names specified by ColIndices. ColIndices can be a positive integer, vector of positive integers, character vector specifying a column name, cell array of character vectors, or a logical vector.

DMObjNew = colnames(DMObj, ColIndices, ColNames) returns DMObjNew, a DataMatrix object with columns specified by ColIndices set to the names specified by ColNames. The number of elements in ColIndices must equal the number of elements in ColNames.

Version History

Introduced in R2008b