This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

rownames (DataMatrix)

Retrieve or set row names of DataMatrix object


ReturnRowNames = rownames(DMObj)
ReturnRowNames = rownames(DMObj, RowIndices)
DMObjNew = rownames(DMObj, RowIndices, RowNames)

Input Arguments


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


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

  • Positive integer

  • Vector of positive integers

  • Character vector specifying a row name

  • Cell array of character vectors

  • Logical vector


Row 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 row names, with row numbers appended to the prefix

  • Logical true or false (default). If true, unique row names are assigned using the format row1, row2, row3, etc. If false, no row names are assigned.


The number of elements in RowNames must equal the number of elements in RowIndices.

Output Arguments

ReturnRowNamesCharacter vector or cell array of character vectors containing row names in DMObj.

DataMatrix object created with names specified by RowIndices and RowNames.


ReturnRowNames = rownames(DMObj) returns ReturnRowNames, a cell array of character vectors specifying the row names in DMObj, a DataMatrix object.

ReturnRowNames = rownames(DMObj, RowIndices) returns the row names specified by RowIndices. RowIndices can be a positive integer, vector of positive integers, character vector specifying a row name, cell array of character vectors, or a logical vector.

DMObjNew = rownames(DMObj, RowIndices, RowNames) returns DMObjNew, a DataMatrix object with rows specified by RowIndices set to the names specified by RowNames. The number of elements in RowIndices must equal the number of elements in RowNames.

Introduced in R2008b

Was this topic helpful?